Changeset 2221 for code/branches/questsystem2
- Timestamp:
- Nov 19, 2008, 11:50:03 AM (16 years ago)
- Location:
- code/branches/questsystem2/src/orxonox/objects
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.h
r2205 r2221 48 48 @brief 49 49 Adds a Quest, resp. changes the quests status to active for the player invoking the Quest. 50 51 Creating a AddQuest through XML goes as follows: 52 53 <AddQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added. 50 54 @author 51 55 Damian 'Mozork' Frick -
code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.h
r2205 r2221 47 47 @brief 48 48 Adds a QuestHint, resp. activates the QuestHint of the given id for the player the QuestEffect is invoked on. 49 50 Creating a AddQuestHint through XML goes as follows: 51 52 <AddQuestHint hintId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added. 49 53 @author 50 54 Damian 'Mozork' Frick -
code/branches/questsystem2/src/orxonox/objects/quest/AddReward.h
r2205 r2221 48 48 @brief 49 49 Adds a list of Rewardables to a player. 50 51 Creating a AddReward through XML goes as follows: 52 53 <AddReward> 54 <Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations. 55 ... 56 <Rewardable /> 57 </AddReward> 50 58 @author 51 59 Damian 'Mozork' Frick -
code/branches/questsystem2/src/orxonox/objects/quest/CompleteQuest.h
r2205 r2221 48 48 @brief 49 49 Completes a Quest (with a specified id) for the player invoking the QuestEffect. 50 51 Creating a CompleteQuest through XML goes as follows: 52 53 <CompleteQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be completed. 50 54 @author 51 55 Damian 'Mozork' Frick -
code/branches/questsystem2/src/orxonox/objects/quest/FailQuest.h
r2205 r2221 47 47 /** 48 48 @brief 49 Fails a quest. 49 Fails a quest (with a specified id) for the player invoking the QuestEffect. 50 51 Creating a FailQuest through XML goes as follows: 52 53 <FailQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be failed. 50 54 @author 51 55 Damian 'Mozork' Frick -
code/branches/questsystem2/src/orxonox/objects/quest/QuestDescription.h
r2191 r2221 49 49 This class is a description of a QuestItem. 50 50 It holds a title and a description. 51 52 Creating a QuestDescription through XML goes as follows: 53 54 <QuestDescription title="Title" description="Description Text" /> 51 55 @author 52 56 Damian 'Mozork' Frick -
code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.cc
r2209 r2221 27 27 */ 28 28 29 /** 30 @file QuestEffectBeacon.cc 31 @brief 32 Implementation of the QuestEffectBeacon class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "QuestEffectBeacon.h" … … 44 50 CreateFactory(QuestEffectBeacon); 45 51 52 /** 53 @brief 54 Constructor. Registers the object and initializes defaults. 55 */ 46 56 QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : PositionableEntity(creator) 47 57 { … … 49 59 50 60 this->status_ = QuestEffectBeaconStatus::active; 51 this->times_ = -1; 52 this->trigger_ = NULL; 53 } 54 61 this->times_ = INFINITE; 62 } 63 64 /** 65 Destructor. 66 */ 55 67 QuestEffectBeacon::~QuestEffectBeacon() 56 68 { 57 69 } 58 70 71 /** 72 @brief 73 Method for creating a QuestEffectBeacon object through XML. 74 */ 59 75 void QuestEffectBeacon::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 76 { … … 62 78 63 79 XMLPortParam(QuestEffectBeacon, "times", setTimes, getTimes, xmlelement, mode); 64 XMLPortObject(QuestEffectBeacon, QuestEffect, "", addEffect, getEffect, xmlelement, mode); 65 XMLPortObject(QuestEffectBeacon, PlayerTrigger, "", addTrigger, getTrigger, xmlelement, mode); 66 } 67 80 XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode); 81 } 82 83 /** 84 @brief 85 Processes an event for this QuestEffectBeacon. 86 */ 68 87 void QuestEffectBeacon::processEvent(Event& event) 69 88 { 89 SUPER(QuestEffectBeacon, processEvent, event); 90 70 91 SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger); 71 92 } 72 93 94 /** 95 @brief 96 Executes the QuestEffectBeacon. 97 This means extracting the ControllableEntity from the PlayerTrigger, provided by the Event causing the execution, and the extracting the PlayerInfo from the received ControllableEntity and invoking the QuestEffectbeacon's QuestEffects on the received PlayerInfo. 98 @param b 99 TDO: What is this??? 100 @param trigger 101 Apointer to the PlayerTrigger that threw the Event. 102 @return 103 Returns true if successfully executed, false if not. 104 */ 73 105 bool QuestEffectBeacon::execute(bool b, PlayerTrigger* trigger) 74 106 { 75 107 if(!b) 76 108 { 109 //TDO: Better message, please. 77 110 COUT(2) << "b is false." << std::endl; 78 111 } 79 if(!(this->isActive())) 112 if(!(this->isActive())) //!< If the QuestEffectBeacon is inactive it cannot be executed. 80 113 { 81 114 COUT(3) << "The QuestEffectBeacon is inactive." << std::endl; 82 115 return false; 83 116 } 84 117 118 if(!trigger->isForPlayer()) //!< The PlayerTrigger is not exclusively for ControllableEntities which means we cannot extract one. 119 { 120 return false; 121 } 122 123 //! Extracting the ControllableEntity form the PlayerTrigger. 85 124 ControllableEntity* entity = trigger->getTriggeringPlayer(); 86 125 … … 91 130 } 92 131 132 //! Extract the PlayerInfo from the ControllableEntity. 93 133 PlayerInfo* player = entity->getPlayer(); 94 134 … … 99 139 } 100 140 101 COUT(3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl; 102 103 bool check = QuestEffect::invokeEffects(player, this->effects_); 141 COUT(3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl; 142 143 bool check = QuestEffect::invokeEffects(player, this->effects_); //!< Invoke the QuestEffects on the PlayerInfo. 104 144 if(check) 105 145 { 106 this->decrementTimes(); 146 this->decrementTimes(); //!< Decrement the number of times the beacon can be used. 107 147 return true; 108 148 } 109 149 110 150 return false; 111 151 } 112 152 113 bool QuestEffectBeacon::isActive(void) 114 { 115 return this->status_ == QuestEffectBeaconStatus::active; 116 } 117 153 /** 154 @brief 155 Set the status of the QuestEffectBeacon. 156 @param activate 157 If true the QuestEffectBeacon is activated, if false it is deactivated. 158 @return 159 Returns whether the activation/deactivation was successful. 160 */ 161 bool QuestEffectBeacon::setActive(bool activate) 162 { 163 if(this->getTimes() == 0 && activate) //!< A QuestEffectBeacon that can be executed only 0 times is always inactive. 164 { 165 return false; 166 } 167 168 if(activate) 169 { 170 this->status_ = QuestEffectBeaconStatus::active; 171 return true; 172 } 173 174 this->status_ = QuestEffectBeaconStatus::inactive; 175 return true; 176 } 177 178 /** 179 @brief 180 Decrement the number of times the QuestEffectBeacon can be executed. 181 @return 182 Returns true if successful. 183 */ 118 184 bool QuestEffectBeacon::decrementTimes(void) 119 185 { 120 if(!(this->isActive())) 121 { 122 return false; 123 } 124 if(this->getTimes() == -1)186 if(!(this->isActive())) //!< The QuestEffectBeacon mus be active to decrement the number of times it can be executed. 187 { 188 return false; 189 } 190 if(this->getTimes() == INFINITE) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times. 125 191 { 126 192 return true; 127 193 } 128 194 129 this->times_ = this->times_ - 1; 130 if(this->getTimes() == 0) 195 this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed. 196 if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 131 197 { 132 198 this->status_ = QuestEffectBeaconStatus::inactive; … … 136 202 } 137 203 138 204 /** 205 @brief 206 Set the number of times the QuestEffectBeacon can be executed. 207 The number must be eighter <= 0, or INFINITY which is '-1'. 208 @param n 209 The number of times the QuestEffectBeacon can be executed. 210 The number must be eighter <= 0, or INFINITY which is '-1'. 211 @return 212 Returns true if successful. 213 */ 139 214 bool QuestEffectBeacon::setTimes(const int & n) 140 215 { 141 if(n < -1)216 if(n < 0 && n != INFINITE) 142 217 { 143 218 return false; … … 148 223 } 149 224 150 151 /** 152 @brief 153 225 /** 226 @brief 227 Adds a QuestEffect to the QuestEffectBeacon. 228 @param effect 229 A pointer to the QuestEffect to be added. 230 @return 231 Returns true if successful. 154 232 */ 155 233 bool QuestEffectBeacon::addEffect(QuestEffect* effect) 156 234 { 157 if(effect == NULL) 235 if(effect == NULL) //!< NULL-pointers are not well liked here... 158 236 { 159 237 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 167 245 } 168 246 169 bool QuestEffectBeacon::addTrigger(PlayerTrigger* trigger) 170 { 171 if(this->trigger_ != NULL) 172 { 173 COUT(2) << "A Trigger was trying to be added, where one was already set." << std::endl; 174 return false; 175 } 176 if(trigger == NULL) 177 { 178 COUT(2) << "A NULL-Trigger was trying to be added." << std::endl; 179 return false; 180 } 181 182 COUT(3) << "A Trigger was added to a QuestEffectBeacon." << std::endl; 183 this->trigger_ = trigger; 184 return true; 185 } 186 187 /** 188 @brief 189 247 /** 248 @brief 249 Returns the QuestEffect at the given index. 250 @param index 251 The index. 252 @return 253 Returns a pointer to the QuestEffect at the given index. 190 254 */ 191 255 const QuestEffect* QuestEffectBeacon::getEffect(unsigned int index) const … … 203 267 } 204 268 205 const PlayerTrigger* QuestEffectBeacon::getTrigger(unsigned int index) const206 {207 if(index == 0)208 {209 return this->trigger_;210 }211 212 return NULL;213 }214 215 269 } -
code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.h
r2209 r2221 27 27 */ 28 28 29 /** 30 @file QuestEffectBeacon.h 31 @brief 32 Definition of the QuestEffectBeacon class. 33 */ 34 29 35 #ifndef _QuestEffectBeacon_H__ 30 36 #define _QuestEffectBeacon_H__ … … 37 43 { 38 44 45 //! The status of the beacon, can be either active or inactive. 39 46 enum Enum 40 47 { … … 42 49 active 43 50 }; 44 51 45 52 } 46 53 … … 49 56 /** 50 57 @brief 51 A QuestEffectBeacon is a n entitywhich can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s).58 A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s). 52 59 The conditions under which the QuestEffects are invoked on the player are defined by Triggers. 53 60 A QuestEffectBeacon can be executed a defined number of times. 61 A QuestEffectBeacon can be inactive or active. 62 63 Creating a QuestEffectBeacon through XML goes as follows: 64 65 <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times. 66 <effects> 67 <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation. 68 ... 69 <QuestEffect /> 70 </effects> 71 <events> 72 <execute> 73 <PlayerTrigger /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon. 74 </execute> 75 </events> 76 </QuestEffectBeacon> 54 77 @author 55 78 Damian 'Mozork' Frick … … 61 84 virtual ~QuestEffectBeacon(); 62 85 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 86 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML. 64 87 65 virtual void processEvent(Event& event); 88 virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon. 66 89 67 90 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. 68 91 69 bool isActive(void); //!< Test whether the QuestEffectBeacon is active. 92 /** 93 @brief Tests whether the QuestEffectBeacon is active. 94 @return Returns true if the QuestEffectBeacon is active, fals if not. 95 */ 96 inline bool isActive(void) 97 { return this->status_ == QuestEffectBeaconStatus::active; } 98 99 bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon. 70 100 71 101 protected: 72 102 bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed. 73 103 74 inline const int & getTimes(void) const //!< Return the number of times the QUestEffectBeacon can still be executed. 104 /** 105 @brief Returns the number of times the QUestEffectBeacon can still be executed. 106 @return Returns the number of times the QUestEffectBeacon can still be executed. 107 */ 108 inline const int & getTimes(void) const 75 109 { return this->times_; } 76 110 77 111 private: 112 static const int INFINITE = -1; //!< Constant to avoid using magic numbers. 113 78 114 std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player. 79 115 int times_; //!< Number of times the beacon can be exectued. 80 116 QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive. 81 PlayerTrigger* trigger_;82 117 83 118 bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed. 84 bool addEffect(QuestEffect* effect); 85 bool addTrigger(PlayerTrigger* trigger); 119 bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon. 86 120 87 const QuestEffect* getEffect(unsigned int index) const; 88 const PlayerTrigger* getTrigger(unsigned int index) const; 121 const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index. 89 122 90 123 }; -
code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
r2209 r2221 35 35 #include "core/XMLPort.h" 36 36 37 #include "orxonox/objects/worldentities/ControllableEntity.h" 38 37 39 namespace orxonox 38 40 { … … 45 47 this->distance_ = 100; 46 48 this->targetMask_.exclude(Class(BaseObject)); 47 this->setForPlayer(false); 49 this->setForPlayer(false); //!< Normally hasn't just ControllableEntities as targets. 48 50 } 49 51 … … 83 85 void DistanceTrigger::addTargets(const std::string& targets) 84 86 { 85 86 if(targets == "ControllableEntity") 87 Identifier* targetId = ClassByString(targets); 88 89 //! Checks whether the target is (or is derived from) a ControllableEntity. 90 Identifier* controllableEntityId = Class(ControllableEntity); 91 if(targetId->isA(controllableEntityId)) 87 92 { 88 93 this->setForPlayer(true); 89 94 } 90 91 Identifier* targetId = ClassByString(targets); 95 92 96 if (!targetId) 93 97 { … … 125 129 if (distanceVec.length() < this->distance_) 126 130 { 131 132 //! If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity. 127 133 if(this->isForPlayer()) 128 134 { 129 130 135 ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity); 136 this->setTriggeringPlayer(player); 131 137 } 132 138 -
code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/PlayerTrigger.cc
r2196 r2221 27 27 */ 28 28 29 /** 30 @file PlayerTrigger.cc 31 @brief 32 Implementation of the PlayerTrigger class. 33 */ 34 35 #include "OrxonoxStableHeaders.h" 36 #include "PlayerTrigger.h" 37 29 38 #include "core/CoreIncludes.h" 30 31 #include "PlayerTrigger.h"32 39 33 40 namespace orxonox { 34 41 42 /** 43 @brief 44 Constructor. Registers the object and initializes defaults. 45 */ 35 46 PlayerTrigger::PlayerTrigger(BaseObject* creator) : Trigger(creator) 36 47 { … … 41 52 } 42 53 43 54 /** 55 @brief 56 Destructor. 57 */ 44 58 PlayerTrigger::~PlayerTrigger() 45 59 { 46 60 } 47 61 62 /** 63 @brief 64 Method for creating a QuestEffectBeacon object through XML. 65 */ 48 66 void PlayerTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 67 { -
code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
r2196 r2221 26 26 * 27 27 */ 28 28 29 /** 30 @file PlayerTrigger.h 31 @brief 32 Definition of the PlayerTrigger class. 33 */ 34 29 35 #ifndef _PlayerTrigger_H__ 30 36 #define _PlayerTrigger_H__ 37 38 #include "OrxonoxPrereqs.h" 31 39 32 40 #include "Trigger.h" … … 36 44 /** 37 45 @brief 38 46 A PlayerTrigger is a trigger which is normally triggered by ControllableEntities and can as such return a pointer to the ControllableEntity which triggered it. 39 47 @author 40 48 Damian 'Mozork' Frick … … 46 54 virtual ~PlayerTrigger(); 47 55 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML. 49 57 58 /** 59 @brief Returns the player that triggered the PlayerTrigger. 60 @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger. 61 */ 50 62 inline ControllableEntity* getTriggeringPlayer(void) const 51 63 { return this->player_; } 64 65 /** 66 @brief Checks whether the PlayerTrigger normally returns a ControllableEntity. 67 @return Returns true if the PlayerTrigger normally returns a ControllableEntity. 68 */ 69 inline bool isForPlayer(void) const 70 { return this->isForPlayer_; } 52 71 53 72 protected: 54 73 virtual bool isTriggered(TriggerMode mode) = 0; 55 74 75 /** 76 @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger. 77 @param player A pointer to the ControllableEntity that triggered the PlayerTrigger. 78 */ 56 79 inline void setTriggeringPlayer(ControllableEntity* player) 57 80 { this->player_ = player; } 58 inline bool isForPlayer(void) const 59 { return this->isForPlayer_; } 81 82 /** 83 @brief Set whether the PlayerTrigger normally is triggered by ControllableEntities. 84 @param isForPlayer Should be true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities, false if not. 85 */ 60 86 inline void setForPlayer(bool isForPlayer) 61 87 { this->isForPlayer_ = isForPlayer; } 62 88 63 89 private: 64 ControllableEntity* player_; 65 bool isForPlayer_; 90 ControllableEntity* player_; //!< The player that triggered the PlayerTrigger. 91 bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities. 66 92 67 93 };
Note: See TracChangeset
for help on using the changeset viewer.