Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2008, 4:40:00 PM (16 years ago)
Author:
dafrick
Message:
  • Created QuestListeners, they can be used to affect Objects due to status changes of quests.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem3/src/orxonox/objects/quest/GlobalQuest.cc

    r2261 r2328  
    3838#include "orxonox/objects/infos/PlayerInfo.h"
    3939#include "core/CoreIncludes.h"
     40#include "core/Super.h"
    4041#include "util/Exception.h"
    4142
     
    8889    bool GlobalQuest::fail(PlayerInfo* player)
    8990    {
    90         if(this->isFailable(player)) //!< Check whether the Quest can be failed.
    91         {
    92             this->setStatus(player, questStatus::failed);
    93            
    94             //! Iterate through all players possessing this Quest.
    95             for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    96             {
    97                 QuestEffect::invokeEffects(*it, this->getFailEffectList());
    98             }
    99 
    100             return true;
    101         }
    102        
    103         COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
    104         return false;
     91        if(!this->isFailable(player)) //!< Check whether the Quest can be failed.
     92        {
     93            COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
     94            return false;
     95        }
     96       
     97        Quest::fail(player);
     98       
     99        //! Iterate through all players possessing this Quest.
     100        for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     101        {
     102            QuestEffect::invokeEffects(*it, this->getFailEffectList());
     103        }
     104
     105        return true;
    105106    }
    106107
     
    117118    bool GlobalQuest::complete(PlayerInfo* player)
    118119    {
    119         if(this->isCompletable(player)) //!< Check whether the Quest can be completed.
    120         {
    121             this->setStatus(player, questStatus::completed);
    122            
    123             //! Iterate through all players possessing the Quest.
    124             for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    125             {
    126                 QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
    127             }
    128            
    129             QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
    130             return true;
    131         }
    132        
    133         COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
    134         return false;
     120        if(!this->isCompletable(player)) //!< Check whether the Quest can be completed.
     121        {
     122            COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
     123            return false;
     124        }
     125       
     126        //! Iterate through all players possessing the Quest.
     127        for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     128        {
     129            QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
     130        }
     131       
     132        Quest::complete(player);
     133       
     134        QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
     135        return true;
    135136    }
    136137
Note: See TracChangeset for help on using the changeset viewer.