Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2011, 7:50:43 PM (13 years ago)
Author:
jo
Message:

Ai and tutorial improvements merged back to the trunk. AI features: all weapons are used, the ai-firestrength is configurable, bots are able to collect pickups . I've set the tutorial level as default level.

Location:
code/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/notifications/NotificationDispatcher.cc

    r8858 r8891  
    5050    CreateUnloadableFactory(NotificationDispatcher);
    5151
     52    registerMemberNetworkFunction(NotificationDispatcher, broadcastHelper);
    5253    registerMemberNetworkFunction(NotificationDispatcher, dispatch);
    5354
     
    6162
    6263        this->sender_ = NotificationListener::NONE;
     64        this->bBroadcast_ = false;
    6365        this->registerVariables();
    6466    }
     
    8183        SUPER(NotificationDispatcher, XMLPort, xmlelement, mode);
    8284
    83         XMLPortParam(NotificationDispatcher, "sender", getSender, setSender, xmlelement, mode);
    84        
    85         XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers.
     85        XMLPortParam(NotificationDispatcher, "sender", setSender, getSender, xmlelement, mode);
     86        XMLPortParam(NotificationDispatcher, "broadcast", setBroadcasting, isBroadcasting, xmlelement, mode);
     87
     88        XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode);
    8689    }
    8790
     
    100103    {
    101104        registerVariable(this->sender_, VariableDirection::ToClient);
     105    }
     106
     107    /**
     108    @brief
     109        Broadcasts a specific Notification.
     110    */
     111    void NotificationDispatcher::broadcast(void)
     112    {
     113        // TODO: Needed?
     114        const std::string message = this->createNotificationMessage();
     115        NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::local);
     116
     117        // Broadcast
     118        if(!GameMode::isStandalone())
     119        {
     120            callMemberNetworkFunction(NotificationDispatcher, broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST);
     121        }
     122    }
     123
     124    /**
     125    @brief
     126        Helper function for broadcast.
     127    */
     128    void NotificationDispatcher::broadcastHelper(void)
     129    {
     130        this->dispatch(Host::getPlayerID());
    102131    }
    103132
     
    110139    void NotificationDispatcher::dispatch(unsigned int clientId)
    111140    {
    112         if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == 0x0)
     141        // We don't call sendNotification() directly on the server, because if might be necessary that createNotificationMessage() is executed on the client as the message may be client-specific.
     142        if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == ObjectDirection::None)
    113143        {
    114144            const std::string message = this->createNotificationMessage();
     
    139169        orxout(verbose, context::notifications) << "NotificationDispatcher (&" << this << ") triggered." << endl;
    140170
     171        // If the NotificationDispatcher is set to broadcast.
     172        if(this->isBroadcasting())
     173        {
     174            this->broadcast();
     175            return true;
     176        }
     177
    141178        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142179        PlayerInfo* player = NULL;
  • code/trunk/src/modules/notifications/NotificationDispatcher.h

    r7552 r8891  
    5050        A NotificationDispatcher is an entity that, upon being triggered, dispatches (or sends) a specified @ref orxonox::Notification "Notification".
    5151
    52         There is one parameter to be set, the @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher.
     52        There are two parameter to be set:
     53        - The @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher.
     54        - The @b broadcast . Specifies whether messages are broadcast (i.e. sent to all clients) or just sent to a specific player.
    5355
    5456        Its standard usage is:
     
    6264        </NotificationDispatcher>
    6365        @endcode
    64         But keep in mind, that NotificationDispatcher is an abstract class and in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger".
     66        But keep in mind, that NotificationDispatcher is an abstract class.
     67        Also in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger".
     68        If the NotificationDispatcher is not set to broadcast only events caused by @ref orxonox::PlayerTrigger "PlayerTriggers" trigger a message since the information obtained by the @ref orxonox::PlayerTrigger "PlayerTrigger" is used to identify the client to which the message should be sent.
    6569
    6670    @author
     
    8488            const std::string& getSender(void) const
    8589                { return this->sender_; }
    86                         /**
     90            /**
    8791            @brief Set the sender of the Notification dispatched by this NotificationDispatcher.
    8892            @param sender The name of the sender.
     
    9195                { this->sender_ = sender; }
    9296
    93             void dispatch(unsigned int clientId); //!< Dispatches a specific Notification.
     97            /**
     98            @brief Check whether the NotificationDispatcher is set to broadcast.
     99            @return Returns true if the NotificationDispatcher is set to broadcast.
     100            */
     101            bool isBroadcasting(void) const
     102                { return this->bBroadcast_; }
     103            /**
     104            @brief Set the NotificationDispatcher to broadcast.
     105            @param broadcast Whether the NotificationDispatcher is set to broadcast or singlecast.
     106            */
     107            void setBroadcasting(bool v)
     108                { this->bBroadcast_ = v; }
     109
     110            void broadcast(void); //!< Broadcasts a specific Notification.
     111            void broadcastHelper(void); //!< Helper function for broadcast.
     112            void dispatch(unsigned int clientId); //!< Dispatches a specific Notification to a given client.
    94113            bool trigger(bool triggered, BaseObject* trigger); //!< Is called when the NotificationDispatcher is triggered.
    95114
    96115        protected:
    97116            std::string sender_; //!< The name of the sender of the Notification dispatched by this NotificationDispatcher.
     117            bool bBroadcast_; //!< Whether the NotificationDispatcher is broadcasting.
    98118
    99119            void registerVariables(void); //!< Register some variables for synchronisation.
     
    105125            */
    106126            virtual const std::string& createNotificationMessage(void)
    107                 { return *(new std::string("")); }
     127                { return BLANKSTRING; }
    108128
    109129    };
  • code/trunk/src/modules/overlays/hud/HUDNavigation.cc

    r8858 r8891  
    6363{
    6464  SetConfigValue(markerLimit_, 3);
     65
    6566}
    6667
     
    7778    setTextSize ( 0.05f );
    7879    setNavMarkerSize ( 0.05f );
     80    setDetectionLimit( 10000.0f );
    7981}
    8082
     
    9597    SUPER ( HUDNavigation, XMLPort, xmlelement, mode );
    9698
    97     XMLPortParam ( HUDNavigation, "font",          setFont,          getFont,          xmlelement, mode );
    98     XMLPortParam ( HUDNavigation, "textSize",      setTextSize,      getTextSize,      xmlelement, mode );
    99     XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode );
     99    XMLPortParam ( HUDNavigation, "font",           setFont,           getFont,           xmlelement, mode );
     100    XMLPortParam ( HUDNavigation, "textSize",       setTextSize,       getTextSize,       xmlelement, mode );
     101    XMLPortParam ( HUDNavigation, "navMarkerSize",  setNavMarkerSize,  getNavMarkerSize,  xmlelement, mode );
     102    XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode );
    100103}
    101104
     
    161164
    162165    unsigned int markerCount_ = 0;
    163 
     166    bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player
    164167//         for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
    165168    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt )
    166169    {
    167170        ObjectMap::iterator it = activeObjectList_.find ( listIt->first );
    168 
    169         if ( markerCount_ < markerLimit_ )
     171        closeEnough_ = listIt->second < detectionLimit_ ;
     172        if ( markerCount_ < markerLimit_ && (closeEnough_ ||  detectionLimit_ < 0) ) // display on HUD if the statement is true
    170173        {
    171174
     
    277280            it->second.text_->show();
    278281        }
    279         else
     282        else // do not display on HUD
    280283        {
    281284            it->second.panel_->hide();
     
    309312void HUDNavigation::addObject ( RadarViewable* object )
    310313{
    311     if( showObject(object)==false )
     314    if( showObject(object) == false )
    312315        return;
    313316
     
    396399        return false;
    397400    assert( rv->getWorldEntity() );
    398     if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
     401    if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false )
    399402        return false;
    400403    return true;
  • code/trunk/src/modules/overlays/hud/HUDNavigation.h

    r7401 r8891  
    8585    { return navMarkerSize_; }
    8686
     87    void setDetectionLimit( float limit )
     88    { this->detectionLimit_ = limit; }
     89    float getDetectionLimit() const
     90    { return this->detectionLimit_; }
     91
    8792    void setTextSize ( float size );
    8893    float getTextSize() const;
     
    102107    float textSize_;
    103108
    104     unsigned int markerLimit_;; //TODO: is it possible to set this over the console and/or the IG-Setting
    105 
    106 
     109    unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting
     110    float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value.
     111                           //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite".
    107112};
    108113}
  • code/trunk/src/modules/overlays/hud/HUDRadar.cc

    r8858 r8891  
    6464        this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png";
    6565        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.png";
    66 
     66        this->setDetectionLimit( 10000.0f );
    6767        this->owner_ = 0;
    6868    }
     
    9393    {
    9494        if (object == dynamic_cast<RadarViewable*>(this->owner_))
     95            return;
     96        if( showObject(object) == false ) //do not show objects that are "invisible" or "radar invisible"
    9597            return;
    9698
     
    123125
    124126    void HUDRadar::objectChanged( RadarViewable* rv )
    125     {
    126         if (rv == dynamic_cast<RadarViewable*>(this->owner_))
    127             return;
    128         assert( this->radarObjects_.find(rv) != this->radarObjects_.end() );
    129         Ogre::PanelOverlayElement* panel = this->radarObjects_[rv];
    130         panel->setMaterialName(TextureGenerator::getMaterialName(
    131             shapeMaterials_[rv->getRadarObjectShape()], rv->getRadarObjectColour()));
     127    {// The new implementation behaves more precisely, since inactive RadarViewables are not displayed anymore.
     128        this->removeObject(rv);
     129        this->addObject(rv);
    132130    }
    133131
     
    174172            coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
    175173            it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
    176             it->second->show();
     174            if( distance < detectionLimit_ || detectionLimit_ < 0 )
     175                it->second->show();
     176            else
     177                it->second->hide();
    177178
    178179            // if this object is in focus, then set the focus marker
     
    186187    }
    187188
     189    bool HUDRadar::showObject(RadarViewable* rv)
     190    {
     191        if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
     192            return false;
     193        assert( rv->getWorldEntity() );
     194        if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
     195            return false;
     196        return true;
     197    }
     198
     199
    188200    void HUDRadar::changedOwner()
    189201    {
  • code/trunk/src/modules/overlays/hud/HUDRadar.h

    r7880 r8891  
    5757        void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; }
    5858
     59        void setDetectionLimit( float limit )
     60        { this->detectionLimit_ = limit; }
     61        float getDetectionLimit() const
     62        { return this->detectionLimit_; }
     63
    5964        float getMaximumDotSize() const { return this->maximumDotSize_; }
    6065        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
     
    6974        virtual void objectChanged( RadarViewable* rv );
    7075        void radarTick(float dt);
     76        bool showObject( RadarViewable* rv ); //!< Do not display an object on radar, if showObject(.) is false.
    7177
    7278        void gatherObjects();
     
    8389
    8490        float sensitivity_;
    85 
     91        float detectionLimit_;
    8692        ControllableEntity* owner_;
    8793    };
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r8858 r8891  
    181181        if(GameMode::isMaster() && this->isActive())
    182182        {
    183             SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
     183            WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
    184184
    185185            // Remove PickupCarriers from the blocked list if they have exceeded their time.
     
    195195            for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    196196            {
     197                if(spawner == NULL) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute).
     198                    break;
     199
    197200                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    198201                PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
    199                 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawnder, is in trigger-distance and the carrier is not blocked.
     202                // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawner, is in trigger-distance and the carrier is not blocked.
    200203                if(distance.length() < this->triggerDistance_ && carrier != NULL && this->blocked_.find(carrier) == this->blocked_.end())
    201204                {
  • code/trunk/src/modules/questsystem/QuestItem.h

    r7552 r8891  
    105105            QuestDescription* description_; //!< The QuestDescription of the QuestItem.
    106106
    107             bool registered_;
     107            bool registered_; //!< Whether the QuestItem is registered with the QuestManager.
    108108
    109109    };
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r8858 r8891  
    3535
    3636#include "util/Exception.h"
     37#include "util/OrxAssert.h"
    3738#include "util/ScopedSingletonManager.h"
    3839#include "core/command/ConsoleCommand.h"
     
    6061    {
    6162        RegisterRootObject(QuestManager);
    62 
    6363        orxout(internal_info, context::quests) << "QuestManager created." << endl;
    6464    }
     
    9595    bool QuestManager::registerQuest(Quest* quest)
    9696    {
    97         assert(quest);
     97        if(quest == NULL)
     98        {
     99            COUT(1) << "Quest pointer is NULL." << endl;
     100            return false;
     101        }
    98102
    99103        std::pair<std::map<std::string, Quest*>::iterator,bool> result;
     
    133137    bool QuestManager::registerHint(QuestHint* hint)
    134138    {
    135         assert(hint);
     139        if(hint == NULL)
     140        {
     141            COUT(1) << "Hint pointer is NULL." << endl;
     142            return false;
     143        }
    136144
    137145        std::pair<std::map<std::string, QuestHint*>::iterator,bool> result;
     
    361369    Quest* QuestManager::getParentQuest(Quest* quest)
    362370    {
     371        OrxAssert(quest, "The input Quest is NULL.");
    363372        return quest->getParentQuest();
    364373    }
     
    374383    QuestDescription* QuestManager::getDescription(Quest* item)
    375384    {
     385        OrxAssert(item, "The input Quest is NULL.");
    376386        return item->getDescription();
    377387    }
     
    387397    QuestDescription* QuestManager::getDescription(QuestHint* item)
    388398    {
     399        OrxAssert(item, "The input QuestHint is NULL.");
    389400        return item->getDescription();
    390401    }
     
    400411    const std::string QuestManager::getId(Quest* item) const
    401412    {
     413        OrxAssert(item, "The input Quest is NULL.");
    402414        return item->getId();
    403415    }
     
    413425    const std::string QuestManager::getId(QuestHint* item) const
    414426    {
     427        OrxAssert(item, "The input QuestHint is NULL.");
    415428        return item->getId();
    416429    }
  • code/trunk/src/modules/weapons/projectiles/Rocket.cc

    r8855 r8891  
    6666        this->localAngularVelocity_ = 0;
    6767        this->lifetime_ = 100.0f;
     68        this->bIsRocket_= true;
    6869
    6970        if (GameMode::isMaster())
     
    134135        if(this->isInitialized())
    135136        {
     137            this->bIsRocket_= false;
    136138            if (GameMode::isMaster())
    137139            {
Note: See TracChangeset for help on using the changeset viewer.