Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2012, 11:08:17 PM (12 years ago)
Author:
landauf
Message:

merged branch presentation2012merge back to trunk

Location:
code/trunk
Files:
1 deleted
39 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/CMakeLists.txt

    r8858 r9348  
    5050ADD_SUBDIRECTORY(items)
    5151ADD_SUBDIRECTORY(overlays)
    52 ADD_SUBDIRECTORY(pickup)
    5352ADD_SUBDIRECTORY(sound)
    5453ADD_SUBDIRECTORY(weaponsystem)
  • code/trunk/src/orxonox/CameraManager.cc

    r8079 r9348  
    4848    CameraManager::CameraManager()
    4949    {
     50        RegisterRootObject(CameraManager);
     51
    5052        assert(GameMode::showsGraphics());
    5153    }
  • code/trunk/src/orxonox/LevelInfo.cc

    r9016 r9348  
    4242
    4343    // LevelInfoItem
    44    
     44
    4545    //! The list of allowed tags.
    4646    /*static*/ std::set<std::string> LevelInfoItem::possibleTags_s = std::set<std::string>();
     
    9393            LevelInfoItem::possibleTags_s.insert("gametype");
    9494            LevelInfoItem::possibleTags_s.insert("minigame");
     95            LevelInfoItem::possibleTags_s.insert("shipselection");
    9596        }
    9697    }
     
    106107        SubString substr = SubString(tags, ",", " "); // Split the string into tags.
    107108        const std::vector<std::string>& strings = substr.getAllStrings();
     109        for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
     110            this->addTag(*it, false);
     111
     112        this->tagsUpdated();
     113    }
     114    /**
     115    @brief
     116        Set the starting ship models of the level
     117    @param tags
     118        A comma-seperated string of all the allowed ship models for the shipselection.
     119    */
     120    void LevelInfoItem::setStartingShips(const std::string& ships)
     121    {
     122        SubString substr = SubString(ships, ",", " "); // Split the string into tags.
     123        const std::vector<std::string>& strings = substr.getAllStrings();
    108124        for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
    109             this->addTag(*it, false);
    110 
    111         this->tagsUpdated();
     125            this->addStartingShip(*it, false);
     126
     127        this->startingshipsUpdated();
    112128    }
    113129
     
    137153    /**
    138154    @brief
     155        Add a ship model to allowed models for the shipselection
     156    @param ship
     157        The ship model to be added.
     158    @param update
     159        Whether the comma-seperated string of all ship models should be updated. Default is true.
     160    @return
     161        Returns true if the ship was successfully added, if the ship was already present it returns false.
     162    */
     163    bool LevelInfoItem::addStartingShip(const std::string& ship, bool update)
     164    {
     165        bool success = this->startingShips_.insert(ship).second;
     166        if(update && success)
     167            this->startingshipsUpdated();
     168
     169        return success;
     170    }
     171
     172
     173    /**
     174    @brief
    139175        Updates the comma-seperated string of all tags, if the set of tags has changed.
    140176    */
     
    155191    }
    156192
     193    /**
     194    @brief
     195        Updates the comma-seperated string of all ships, if the set of tags has changed.
     196    */
     197    void LevelInfoItem::startingshipsUpdated(void)
     198    {
     199        std::stringstream stream;
     200        std::set<std::string>::iterator temp;
     201        for(std::set<std::string>::iterator it = this->startingShips_.begin(); it != this->startingShips_.end(); )
     202        {
     203            temp = it;
     204            if(++it == this->startingShips_.end()) // If this is the last ship we don't add a comma.
     205                stream << *temp;
     206            else
     207                stream << *temp << ", ";
     208        }
     209
     210        this->startingShipsString_ = std::string(stream.str());
     211    }
     212
     213    void LevelInfoItem::changeStartingShip(const std::string& model)
     214    {
     215        static std::string shipSelectionTag = "shipselection";
     216        //HACK: Read Level XML File, find "shipselection", replace with ship model
     217        std::string levelPath = "../levels/";
     218        levelPath.append(this->getXMLFilename());
     219        std::string tempPath = "../levels/";
     220        tempPath.append("_temp.oxw");
     221        orxout(user_status) << levelPath << endl;
     222        orxout(user_status) << tempPath << endl;
     223        std::ifstream myLevel (levelPath.c_str());
     224        std::ofstream tempLevel (tempPath.c_str());
     225        while(!myLevel.eof())
     226        {
     227            std::string buff;
     228            std::getline(myLevel, buff);
     229            std::string pawndesignString = "pawndesign=";
     230            size_t found = buff.find(pawndesignString.append(shipSelectionTag));
     231            if (found!= std::string::npos)
     232                buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos);
     233            tempLevel.write(buff.c_str(), buff.length());
     234            tempLevel << std::endl;
     235        }
     236        myLevel.close();
     237        tempLevel.close();
     238        orxout(user_status) << "done" << endl;
     239    }
     240
     241
    157242    // LevelInfo
    158243
     
    192277        XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode);
    193278        XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode);
     279        XMLPortParam(LevelInfo, "startingships", setStartingShips, getStartingShips, xmlelement, mode);
    194280    }
    195281
     
    207293        info->setScreenshot(this->getScreenshot());
    208294        info->setTags(this->getTags());
     295        info->setStartingShips(this->getStartingShips());
    209296        return info;
    210297    }
  • code/trunk/src/orxonox/LevelInfo.h

    r9016 r9348  
    4343
    4444#include "core/BaseObject.h"
     45#include <iostream>
     46#include <fstream>
    4547#include "core/OrxonoxClass.h"
    4648
     
    7779            */
    7880            inline const std::string& getName(void) const { return this->name_; } // tolua_export
    79        
     81
    8082            /**
    8183            @brief Set the screenshot of the Level.
     
    116118            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
    117119
     120            void setStartingShips(const std::string& ships); //!< Set the starting ship models of the level
     121            bool addStartingShip(const std::string& ship, bool update = true); //!< Add a model to shipselection
     122            /**
     123            @brief Get the set of starting ship models the Level allows
     124            @return Returns a comma-seperated string of all the allowed ship models for the shipselection.
     125            */
     126            inline const std::string& getStartingShips(void) const
     127                { return this->startingShipsString_; }
     128            /**
     129            @brief Get whether the Level allows a specific starting ship model
     130            @param ship The ship model for which is checked.
     131            @return Returns true if the Level allows the input ship model
     132            */
     133            inline bool hasStartingShip(const std::string& ship) const { return this->startingShips_.find(ship) != this->startingShips_.end(); } // tolua_export
     134            inline void selectStartingShip(const std::string& ship) { this->changeStartingShip(ship); } // tolua_export
    118135            /**
    119136            @brief Get the XML-filename of the Level.
     
    122139            inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export
    123140
     141
    124142        protected:
    125143            /**
     
    133151
    134152        private:
     153            void changeStartingShip (const std::string& model);
     154            void startingshipsUpdated(void); //!< Updates the comma-seperated string of all possible starting ships.
    135155            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
    136 
    137156            static void initializeTags(void); //!< Initialize the set of allowed tags.
    138157            /**
     
    152171            std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
    153172            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
     173            std::set<std::string> startingShips_; //!< The set of starting ship models the Level allows.
     174            std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection.
    154175    }; // tolua_export
    155176
     
    161182        - @b description The description of the level.
    162183        - @b screenshot The screenshot of the level.
    163         - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>.
    164 
     184        - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>, <em>shipselection</em>.
     185        - @b (optional) startingships The comma-seperated string of starting ship models
    165186        An example would be:
    166187        @code
     
    176197    @author
    177198        Damian 'Mozork' Frick
    178 
     199    @edit
     200        Matthias Hutter
    179201    @ingroup Orxonox
    180202    */
     
    186208
    187209            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
    188        
     210
    189211            /**
    190212            @brief Set the screenshot of the Level.
     
    223245            inline const std::string& getTags(void) const
    224246                { return this->LevelInfoItem::getTags(); }
     247            /**
     248            @brief Set the starting ship models of the level
     249            @param A comma-seperated string of all the allowed ship models for the shipselection.
     250            */
     251            inline void setStartingShips(const std::string& ships)
     252                { this->LevelInfoItem::setStartingShips(ships); }
     253            /**
     254            @brief Get the starting ship models of the level
     255            @return Returns a comma-seperated string of all the allowed ship models for the shipselection.
     256            */
     257            inline const std::string& getStartingShips(void) const
     258                { return this->LevelInfoItem::getStartingShips(); }
    225259
    226260            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
    227 
    228261    };
    229262
     
    243276            }
    244277    };
    245    
     278
    246279} // tolua_export
    247280
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r8858 r9348  
    109109    class TeamDeathmatch;
    110110    class UnderAttack;
     111    class TeamGametype;
    111112
    112113    // graphics
     
    150151    class OrxonoxOverlay;
    151152    class OverlayGroup;
    152 
    153     // pickup
    154     class PickupIdentifier;
    155153
    156154    //sound
  • code/trunk/src/orxonox/Scene.cc

    r8858 r9348  
    258258    void Scene::setSkybox(const std::string& skybox)
    259259    {
    260         if (GameMode::showsGraphics() && this->sceneManager_)
    261             this->sceneManager_->setSkyBox(true, skybox);
     260        try
     261        {
     262            if (GameMode::showsGraphics() && this->sceneManager_)
     263                this->sceneManager_->setSkyBox(true, skybox);
     264        }
     265        catch (const Ogre::Exception&)
     266        {
     267            orxout(internal_error) << "Could not load skybox '" << skybox << "':" << endl;
     268            orxout(internal_error) << Exception::handleMessage() << endl;
     269        }
    262270
    263271        this->skybox_ = skybox;
  • code/trunk/src/orxonox/controllers/FormationController.cc

    • Property svn:eol-style set to native
    r9265 r9348  
    5050{
    5151
    52   SetConsoleCommand("FormationController", "formationflight",  &FormationController::formationflight);
    53   SetConsoleCommand("FormationController", "masteraction",     &FormationController::masteraction);
    54   SetConsoleCommand("FormationController", "followme",         &FormationController::followme);
    55   SetConsoleCommand("FormationController", "passivebehaviour", &FormationController::passivebehaviour);
    56   SetConsoleCommand("FormationController", "formationsize",    &FormationController::formationsize);
    57 
    58 
    59 
    60 
    61   static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
    62   static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
    63   static const float FORMATION_LENGTH =  110;
    64   static const float FORMATION_WIDTH =  110;
    65   static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
    66   static const float SPEED_MASTER = 0.6f;
    67   static const float ROTATEFACTOR_MASTER = 0.2f;
    68   static const float SPEED_FREE = 0.8f;
    69   static const float ROTATEFACTOR_FREE = 0.8f;
    70 
    71   FormationController::FormationController(BaseObject* creator) : Controller(creator)
    72   {
     52    SetConsoleCommand("FormationController", "formationflight",  &FormationController::formationflight);
     53    SetConsoleCommand("FormationController", "masteraction",     &FormationController::masteraction);
     54    SetConsoleCommand("FormationController", "followme",         &FormationController::followme);
     55    SetConsoleCommand("FormationController", "passivebehaviour", &FormationController::passivebehaviour);
     56    SetConsoleCommand("FormationController", "formationsize",    &FormationController::formationsize);
     57
     58
     59
     60
     61    static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
     62    static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
     63    static const float FORMATION_LENGTH =  110;
     64    static const float FORMATION_WIDTH =  110;
     65    static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
     66    static const float SPEED_MASTER = 0.6f;
     67    static const float ROTATEFACTOR_MASTER = 0.2f;
     68    static const float SPEED_FREE = 0.8f;
     69    static const float ROTATEFACTOR_FREE = 0.8f;
     70
     71    FormationController::FormationController(BaseObject* creator) : Controller(creator)
     72    {
    7373        RegisterObject(FormationController);
    7474
     
    9191        this->team_=-1;
    9292        this->target_.setCallback(createFunctor(&FormationController::targetDied, this));
    93   }
    94 
    95   FormationController::~FormationController()
    96   {
    97     if (this->isInitialized())
     93    }
     94
     95    FormationController::~FormationController()
     96    {
     97        if (this->isInitialized())
    9898        {
    9999            this->removeFromFormation();
     
    123123            }
    124124        }
    125   }
    126 
    127   void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     125    }
     126
     127    void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    128128    {
    129129        SUPER(FormationController, XMLPort, xmlelement, mode);
     
    137137
    138138
    139   /**
     139    /**
    140140        @brief Activates / deactivates formationflight behaviour
    141141        @param form activate formflight if form is true
    142142    */
    143   void FormationController::formationflight(const bool form)
     143    void FormationController::formationflight(const bool form)
    144144    {
    145145        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
     
    168168    }
    169169
    170   /**
     170    /**
    171171        @brief Get all masters to do a "specific master action"
    172172        @param action which action to perform (integer, so it can be called with a console command (tmp solution))
     
    198198    }
    199199
    200   /**
     200    /**
    201201        @brief Sets shooting behaviour of pawns.
    202202        @param passive if true, bots won't shoot.
     
    225225    }
    226226
    227   /**
     227    /**
    228228        @brief Sets maximal formation size
    229229        @param size maximal formation size.
     
    280280        }
    281281
    282         Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
     282        Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
    283283        float distance = (target - this->getControllableEntity()->getPosition()).length();
    284 
     284        float rotateX = clamp(coord.x * 10, -1.0f, 1.0f);
     285        float rotateY = clamp(coord.y * 10, -1.0f, 1.0f);
    285286
    286287        if(this->state_ == FREE)
     
    289290            {
    290291                // Multiply with ROTATEFACTOR_FREE to make them a bit slower
    291                 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * sgn(coord.x) * coord.x*coord.x);
    292                 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * sgn(coord.y) * coord.y*coord.y);
    293             }
    294 
    295             if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
     292                this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * rotateX);
     293                this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * rotateY);
     294            }
     295
     296            if (this->target_ && distance <  200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
    296297            {
    297298              this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance
     
    305306            if (this->target_ || distance > 10)
    306307            {
    307                 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);
    308                 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);
     308                this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * rotateX);
     309                this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * rotateY);
    309310            }
    310311
     
    320321        {
    321322
    322            this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);
    323            this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);
     323            this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * rotateX);
     324            this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * rotateY);
    324325
    325326            if (distance < 300)
    326327            {
    327                 if (bHasTargetOrientation_)
    328                     {
    329                         copyTargetOrientation();
    330                     }
     328                if (bHasTargetOrientation_)
     329                {
     330                    copyTargetOrientation();
     331                }
    331332                if (distance < 100)
    332                 {   //linear speed reduction
     333                { //linear speed reduction
    333334                    this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
    334 
    335                 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
    336 
    337             } else {
     335                }
     336                else
     337                    this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
     338            }
     339            else
    338340                this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
    339             }
    340341        }
    341342
     
    343344        {
    344345            this->positionReached();
    345             bHasTargetOrientation_=false;
    346         }
    347     }
    348 
    349 
    350 
    351   void FormationController::moveToTargetPosition()
     346            bHasTargetOrientation_=false;
     347        }
     348    }
     349
     350
     351
     352    void FormationController::moveToTargetPosition()
    352353    {
    353354        this->moveToPosition(this->targetPosition_);
    354355    }
    355356
    356   //copy the Roll orientation of given Quaternion.
    357   void FormationController::copyOrientation(const Quaternion& orient)
     357    //copy the Roll orientation of given Quaternion.
     358    void FormationController::copyOrientation(const Quaternion& orient)
    358359    {
    359360        //roll angle difference in radian
     
    373374
    374375
    375    /**
     376    /**
    376377        @brief Unregisters a slave from its master. Initiated by a slave.
    377378    */
     
    463464        }
    464465    }
    465  /**
     466
     467    /**
    466468        @brief Commands the slaves of a master into a formation. Sufficiently fast not to be called within tick. Initiated by a master.
    467469    */
    468 
    469 void FormationController::commandSlaves()
     470    void FormationController::commandSlaves()
    470471    {
    471472        if(this->state_ != MASTER) return;
     
    481482        }
    482483        else
    483         // formation:
     484        // formation:
    484485        {
    485486            dest += 1.0f*orient*WorldEntity::BACK;
    486487            Vector3 pos = Vector3::ZERO;
    487                  bool left=true;
     488            bool left=true;
    488489            int i = 1;
    489490
     
    683684
    684685        if (specificMasterActionHoldCount_ == 0)
    685          {
     686        {
    686687            this->specificMasterAction_ = NONE;
    687688            this->searchNewTarget();
    688          }
    689         else specificMasterActionHoldCount_--;
     689        }
     690        else
     691            specificMasterActionHoldCount_--;
    690692    }
    691693
     
    711713    void FormationController::turn180()
    712714    {
    713             Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
    714 
    715             this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
    716             this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
    717 
    718             this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
     715        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
     716
     717        this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
     718        this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
     719
     720        this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
    719721    }
    720722
     
    734736    void FormationController::spin()
    735737    {
    736             this->moveToTargetPosition();
    737             this->getControllableEntity()->rotateRoll(0.8f);
     738        this->moveToTargetPosition();
     739        this->getControllableEntity()->rotateRoll(0.8f);
    738740    }
    739741
     
    773775        if((humanPawn != NULL) && (allMasters.size() != 0))
    774776        {
    775                 float posHuman = humanPawn->getPosition().length();
    776                 float distance = 0.0f;
    777                 float minDistance = FLT_MAX;
    778                 int index = 0;
    779                 int i = 0;
    780 
    781                 for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
    782                     {
    783                         if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
    784                         distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
    785                         if(distance < minDistance) index = i;
    786                     }
    787                 allMasters[index]->followInit(humanPawn);
    788             }
    789 
    790     }
    791 
    792 
    793 
    794 
     777            float posHuman = humanPawn->getPosition().length();
     778            float distance = 0.0f;
     779            float minDistance = FLT_MAX;
     780            int index = 0;
     781            int i = 0;
     782
     783            for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
     784            {
     785                if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
     786                distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
     787                if(distance < minDistance) index = i;
     788            }
     789            allMasters[index]->followInit(humanPawn);
     790        }
     791    }
    795792
    796793    /**
     
    814811    }
    815812
    816    /**
     813    /**
    817814        @brief Master begins to follow a randomly chosen human player of the same team. Is a "specific master action".
    818815    */
     
    842839
    843840
    844   /**
     841    /**
    845842        @brief Master follows target with adjusted speed. Called within tick.
    846843    */
     
    854851
    855852
    856   void FormationController::setTargetPosition(const Vector3& target)
     853    void FormationController::setTargetPosition(const Vector3& target)
    857854    {
    858855        this->targetPosition_ = target;
     
    918915    }
    919916
    920   void FormationController::forgetTarget()
     917    void FormationController::forgetTarget()
    921918    {
    922919        this->target_ = 0;
     
    924921    }
    925922
    926    void FormationController::targetDied()
     923    void FormationController::targetDied()
    927924    {
    928925        this->forgetTarget();
     
    930927    }
    931928
    932   bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     929    bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    933930    {
    934931        if (entity1 == entity2)
     
    10541051            return;
    10551052
    1056         Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
     1053        Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
    10571054        float distance = (target - this->getControllableEntity()->getPosition()).length();
    10581055
     
    10601057            {
    10611058                // Multiply with ROTATEFACTOR_FREE to make them a bit slower
    1062                 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * sgn(coord.x) * coord.x*coord.x);
    1063                 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * sgn(coord.y) * coord.y*coord.y);
     1059                this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * clamp(coord.x * 10, -1.0f, 1.0f));
     1060                this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * clamp(coord.y * 10, -1.0f, 1.0f));
    10641061                this->getControllableEntity()->moveFrontBack(SPEED_FREE);
    10651062            }
  • code/trunk/src/orxonox/controllers/FormationController.h

    • Property svn:eol-style set to native
  • code/trunk/src/orxonox/controllers/NewHumanController.cc

    r9016 r9348  
    298298        //Used in HumanController for formationFlight
    299299        HumanController::hit(originator,contactpoint,damage);
    300        
     300
    301301        if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
    302302        {
     
    397397                try
    398398                {
    399                     wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
     399                    wePtr = orxonox_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
    400400                }
    401401                catch (...)
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r8858 r9348  
    7676        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it)
    7777        {
    78             if (dynamic_cast<Synchronisable*>(*it))
    79                 orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << endl;
     78            Synchronisable* synchronisable = orxonox_cast<Synchronisable*>(*it);
     79            if (synchronisable)
     80                orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << synchronisable->getObjectID() << endl;
    8081            else
    8182                orxout(debug_output) << "object: " << it->getIdentifier()->getName() << endl;
  • code/trunk/src/orxonox/gametypes/Deathmatch.cc

    r8858 r9348  
    114114    }
    115115
    116     void Deathmatch::playerScored(PlayerInfo* player)
     116    void Deathmatch::playerScored(PlayerInfo* player, int score)
    117117    {
    118         Gametype::playerScored(player);
     118        Gametype::playerScored(player, score);
    119119
    120120        if (player)
  • code/trunk/src/orxonox/gametypes/Deathmatch.h

    r5781 r9348  
    4848
    4949            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    50             virtual void playerScored(PlayerInfo* player);
     50            virtual void playerScored(PlayerInfo* player, int score = 1);
    5151    };
    5252}
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r8858 r9348  
    3131//Low; Codeoptimierung und Dokumentation
    3232
    33 /*
    34 short gaming manual:
    35 There are three different parties a player can belong to: victim, chaser or killer
    36 Every player starts as chaser. As long as there are not enough victims and killers, you can change your and other player's parties by shooting them.
    37 In order to win you have to earn as much points as possible:
    38 - as victim by escaping the chasers
    39 - as chaser by shooting the victim
    40 - as killer by killing the chasers
    41 
    42 
    43 What you shouldn't do is shooting at players of your own party. By doing so your score will decrease.
    44 P.S: If you don't want to be a victim: Get rid of your part by shooting a chaser.
     33/**
     34@brief
     35    Short Gaming Manual:
     36    There are three different parties a player can belong to: victim, chaser or killer
     37    Every player starts as chaser. As long as there are not enough victims and killers, you can change your and other player's parties by shooting them.
     38    In order to win you have to earn as much points as possible:
     39    - as victim by escaping the chasers
     40    - as chaser by shooting the victim
     41    - as killer by killing the chasers
     42
     43
     44    What you shouldn't do is shooting at players of your own party. By doing so your score will decrease.
     45    P.S: If you don't want to be a victim: Get rid of your part by shooting a chaser.
    4546*/
    4647#include "Dynamicmatch.h"
     
    8182        this->numberOf[killer]=0;
    8283        this->tutorial=true;
    83         this->pointsPerTime=0.0f;
     84        this->pointsPerTime=1.0f;
    8485        this->setHUDTemplate("DynamicmatchHUD");
    8586    }
     
    9596            ColourValue(0.3f, 0.3f, 1.0f),  //piggycolour
    9697            ColourValue(0.3f, 1.0f, 0.3f)   //killercolour  what about black: 0.0f, 0.0f, 0.0f
    97 
    9898        };
    9999        static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
     
    111111        if (victim && victim->getPlayer()) //&& originator && originator->getPlayer() ??
    112112        {
    113         int target= playerParty_[victim->getPlayer()];
    114         int source= playerParty_[originator->getPlayer()];
     113            int target = playerParty_[victim->getPlayer()];
     114            int source = playerParty_[originator->getPlayer()];
    115115
    116116            //Case: Not Enough Pigs: party change (= party management)
     
    151151
    152152                //Give new pig boost
    153                 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     153                SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim);
    154154                this->grantPigBoost(spaceship);
    155155            }
     
    245245                }
    246246                //Give new pig boost
    247                 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     247                SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim);
    248248                this->grantPigBoost(spaceship);
    249249            }
     
    276276            else if (friendlyfire && (source == target))
    277277            {
    278                 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
    279                 if (it != this->players_.end())
    280                     {
    281                         it->second.frags_--;
    282                     }
    283             }
    284         }// from far far away not to be removed!
     278                    this->playerScored(originator->getPlayer(), -1);
     279            }
     280        }
    285281        return false; //default: no damage
    286282    }
     
    296292            if (playerParty_[originator->getPlayer()] == killer) //reward the killer
    297293            {
    298                 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
    299                 if (it != this->players_.end())
    300                 {
    301                     it->second.frags_+=20; //value must be tested
    302                 }
    303             }
    304         return true;
     294                    this->playerScored(originator->getPlayer(), 25);
     295            }
     296            return true;
    305297        }
    306298        else return false;
     
    309301    /**
    310302    @brief
    311         Grant the piggy a boost.
     303        Grant the victim a boost.
    312304    @param spaceship
    313305        The SpaceShip to give the boost.
     
    315307    void Dynamicmatch::grantPigBoost(SpaceShip* spaceship)
    316308    {
    317         // Give pig boost
     309        // Give victim boost
    318310        if (spaceship)
    319311        {
     312            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
     313            if(ptr == NULL)
     314                return;
    320315            spaceship->addSpeedFactor(5);
    321             WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
    322316            ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    323317            executor->setDefaultValue(0, ptr);
     
    374368
    375369        if (this->hasStarted() && !gameEnded_)
    376         {   pointsPerTime =pointsPerTime + dt;
    377             gameTime_ = gameTime_ - dt;
    378             if (pointsPerTime > 2.0f)//hard coded!! should be changed
    379             {
    380                 pointsPerTime=0.0f;
     370        {
     371            pointsPerTime = pointsPerTime + dt; //increase points
     372            gameTime_ = gameTime_ - dt; // decrease game time
     373            if (pointsPerTime > 2.0f) //hard coded points for victim! should be changed
     374            {
     375                pointsPerTime = 0.0f;
    381376                rewardPig();
    382377            }
     
    408403    }
    409404
     405/**
     406    @brief The reward function is called every 2 seconds via the tick function and makes the victim score points.
     407*/
    410408    void Dynamicmatch::rewardPig()
    411409    {
    412410        for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden
    413411        {
    414             if (it->second==piggy)
    415             {
    416                  //Spieler mit der Pig-party frags++
    417                  std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(it->first);// still not sure if right syntax
    418                  if (it2 != this->players_.end())
    419                  {
    420                      it2->second.frags_++;
    421                  }
     412            if (it->second==piggy)//Spieler mit der Pig-party frags++
     413            {
     414                 this->playerScored(it->first);
    422415            }
    423416        }
     
    426419    {
    427420        std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player);
    428         Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     421        Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    429422            if (pawn)
    430423            {
     
    446439    {
    447440        //pigs: 1 + every 6th player is a pig
    448         if ( (1+this->getNumberOfPlayers()/6) > numberOf[piggy])
     441        if ( (1 + getPlayerCount()/6) > numberOf[piggy])
    449442        {
    450443            notEnoughPigs=true;
     
    495488        }
    496489        //killers: every 4th player is a killer
    497         if (getNumberOfPlayers()/4 > numberOf[killer])
     490        if ( static_cast<unsigned int>(getPlayerCount()/4) > numberOf[killer])
    498491        {
    499492            notEnoughKillers=true;
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.h

    r8727 r9348  
    8181            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
    8282
     83
    8384        protected:
     85            inline int getPlayerCount() const
     86                 { return this->numberOf[chaser] + numberOf[piggy] + this->numberOf[killer]; }
    8487
    8588            std::map< PlayerInfo*, int > playerParty_; //player's parties are recorded here
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r9261 r9348  
    301301    }
    302302
    303     void Gametype::playerScored(PlayerInfo* player)
     303    void Gametype::playerScored(PlayerInfo* player, int score)
    304304    {
    305305        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
    306306        if (it != this->players_.end())
    307             it->second.frags_++;
     307            it->second.frags_ += score;
    308308    }
    309309
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r9260 r9348  
    9090            virtual bool playerChangedName(PlayerInfo* player);
    9191
    92             virtual void playerScored(PlayerInfo* player);
     92            virtual void playerScored(PlayerInfo* player, int score = 1);
    9393
    9494            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
     
    153153            virtual void resetTimer(float t);
    154154
     155            /**
     156            @brief Get number of Players in game.
     157            */
    155158            inline unsigned int getNumberOfPlayers() const
    156                 { return this->gtinfo_->getNumberOfPlayers(); }
     159                { return this->players_.size(); }
     160
     161
    157162
    158163        protected:
  • code/trunk/src/orxonox/gametypes/LastManStanding.cc

    r8858 r9348  
    211211            if(!player->getControllableEntity())
    212212                return;
    213             Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     213            Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    214214            if(!pawn)
    215215                return;
  • code/trunk/src/orxonox/gametypes/LastTeamStanding.cc

    r8858 r9348  
    283283            if(!player->getControllableEntity())
    284284                return;
    285             Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     285            Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    286286            if(!pawn)
    287287                return;
  • code/trunk/src/orxonox/gametypes/Mission.cc

    • Property svn:eol-style set to native
    r9016 r9348  
    6363        {
    6464            this->missionAccomplished_ = false;
    65             this->end();
     65            this->end();
    6666        }
    6767    }
     
    7878    {
    7979        Gametype::end();
    80         /*if (this->missionAccomplished_)
     80        /*if (this->missionAccomplished_)
    8181            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    82         else
     82        else
    8383            this->gtinfo_->sendAnnounceMessage("Mission failed!");
    84          * */
     84        */
    8585    }
    8686
  • code/trunk/src/orxonox/gametypes/Mission.h

    • Property svn:eol-style set to native
  • code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc

    r8952 r9348  
    128128
    129129    // collect Points for killing oppenents
    130     void TeamBaseMatch::playerScored(PlayerInfo* player)
     130    void TeamBaseMatch::playerScored(PlayerInfo* player, int score)
    131131    {
    132132        int teamnr = this->getTeam(player);
  • code/trunk/src/orxonox/gametypes/TeamBaseMatch.h

    r5929 r9348  
    4747            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator);
    4848
    49             virtual void playerScored(PlayerInfo* player);
     49            virtual void playerScored(PlayerInfo* player, int score = 1);
    5050            virtual void showPoints();
    5151            virtual void endGame();
  • code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc

    r7182 r9348  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "core/ConfigValueIncludes.h"
    33 #include "interfaces/TeamColourable.h"
    34 #include "worldentities/TeamSpawnPoint.h"
     32#include "chat/ChatManager.h"
     33#include "infos/PlayerInfo.h"
    3534#include "worldentities/pawns/Pawn.h"
    3635
     
    3938    CreateUnloadableFactory(TeamDeathmatch);
    4039
    41     TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : Deathmatch(creator)
     40    TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : TeamGametype(creator)
    4241    {
    4342        RegisterObject(TeamDeathmatch);
    44 
    45         this->teams_ = 2;
    46 
    47         this->setConfigValues();
    4843    }
    4944
    50     void TeamDeathmatch::setConfigValues()
     45    void TeamDeathmatch::start()
    5146    {
    52         SetConfigValue(teams_, 2);
     47        TeamGametype::start();
    5348
    54         static ColourValue colours[] =
    55         {
    56             ColourValue(1.0f, 0.3f, 0.3f),
    57             ColourValue(0.3f, 0.3f, 1.0f),
    58             ColourValue(0.3f, 1.0f, 0.3f),
    59             ColourValue(1.0f, 1.0f, 0.0f)
    60         };
    61         static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
     49        std::string message("The match has started!");
     50        ChatManager::message(message);
     51    }
    6252
    63         SetConfigValue(teamcolours_, defaultcolours);
     53    void TeamDeathmatch::end()
     54    {
     55        TeamGametype::end();
     56
     57        std::string message("The match has ended.");
     58        ChatManager::message(message);
    6459    }
    6560
    6661    void TeamDeathmatch::playerEntered(PlayerInfo* player)
    6762    {
    68         Deathmatch::playerEntered(player);
     63        TeamGametype::playerEntered(player);
    6964
    70         std::vector<unsigned int> playersperteam(this->teams_, 0);
    71 
    72         for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
    73             if (it->second < static_cast<int>(this->teams_) && it->second >= 0)
    74                 playersperteam[it->second]++;
    75 
    76         unsigned int minplayers = static_cast<unsigned int>(-1);
    77         size_t minplayersteam = 0;
    78         for (size_t i = 0; i < this->teams_; ++i)
    79         {
    80             if (playersperteam[i] < minplayers)
    81             {
    82                 minplayers = playersperteam[i];
    83                 minplayersteam = i;
    84             }
    85         }
    86 
    87         this->teamnumbers_[player] = minplayersteam;
     65        const std::string& message = player->getName() + " entered the game";
     66        ChatManager::message(message);
    8867    }
    8968
    9069    bool TeamDeathmatch::playerLeft(PlayerInfo* player)
    9170    {
    92         bool valid_player = Deathmatch::playerLeft(player);
     71        bool valid_player = TeamGametype::playerLeft(player);
    9372
    9473        if (valid_player)
    95             this->teamnumbers_.erase(player);
     74        {
     75            const std::string& message = player->getName() + " left the game";
     76            ChatManager::message(message);
     77        }
     78
     79        return valid_player;
     80    }
     81    bool TeamDeathmatch::playerChangedName(PlayerInfo* player)
     82    {
     83        bool valid_player = TeamGametype::playerChangedName(player);
     84
     85        if (valid_player)
     86        {
     87            const std::string& message = player->getOldName() + " changed name to " + player->getName();
     88            ChatManager::message(message);
     89        }
    9690
    9791        return valid_player;
    9892    }
    9993
    100     bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator)
     94    void TeamDeathmatch::pawnKilled(Pawn* victim, Pawn* killer)
    10195    {
    102         return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
     96        if (victim && victim->getPlayer())
     97        {
     98            std::string message;
     99            if (killer)
     100            {
     101                if (killer->getPlayer())
     102                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     103                else
     104                    message = victim->getPlayer()->getName() + " was killed";
     105            }
     106            else
     107                message = victim->getPlayer()->getName() + " died";
     108
     109            ChatManager::message(message);
     110        }
     111
     112        Gametype::pawnKilled(victim, killer);
    103113    }
    104114
    105     bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
     115    void TeamDeathmatch::playerScored(PlayerInfo* player, int score)
    106116    {
    107         return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    108     }
     117        TeamGametype::playerScored(player, score);
    109118
    110     bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator)
    111     {
    112         return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    113     }
    114 
    115     SpawnPoint* TeamDeathmatch::getBestSpawnPoint(PlayerInfo* player) const
    116     {
    117         int desiredTeamNr = -1;
    118         std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
    119         if (it_player != this->teamnumbers_.end())
    120             desiredTeamNr = it_player->second;
    121 
    122         // Only use spawnpoints of the own team (or non-team-spawnpoints)
    123         std::set<SpawnPoint*> teamSpawnPoints = this->spawnpoints_;
    124         for (std::set<SpawnPoint*>::iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); )
     119        if (player)
    125120        {
    126             if ((*it)->isA(Class(TeamSpawnPoint)))
    127             {
    128                 TeamSpawnPoint* tsp = orxonox_cast<TeamSpawnPoint*>(*it);
    129                 if (tsp && static_cast<int>(tsp->getTeamNumber()) != desiredTeamNr)
    130                 {
    131                     teamSpawnPoints.erase(it++);
    132                     continue;
    133                 }
    134             }
    135 
    136             ++it;
    137         }
    138 
    139         SpawnPoint* fallbackSpawnPoint = NULL;
    140         if (teamSpawnPoints.size() > 0)
    141         {
    142             unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
    143             unsigned int index = 0;
    144             // Get random fallback spawnpoint in case there is no active SpawnPoint.
    145             for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
    146             {
    147                 if (index == randomspawn)
    148                 {
    149                     fallbackSpawnPoint = (*it);
    150                     break;
    151                 }
    152 
    153                 ++index;
    154             }
    155 
    156             // Remove all inactive SpawnPoints from the list.
    157             for (std::set<SpawnPoint*>::iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); )
    158             {
    159                 if(!(*it)->isActive())
    160                 {
    161                     teamSpawnPoints.erase(it++);
    162                     continue;
    163                 }
    164 
    165                 ++it;
    166             }
    167 
    168             randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
    169             index = 0;
    170             for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
    171             {
    172                 if (index == randomspawn)
    173                     return (*it);
    174 
    175                 ++index;
    176             }
    177 
    178             return fallbackSpawnPoint;
    179         }
    180 
    181         return 0;
    182     }
    183 
    184     void TeamDeathmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
    185     {
    186         if (!player)
    187             return;
    188 
    189         // Set the team colour
    190         std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
    191         if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < static_cast<int>(this->teamcolours_.size()))
    192         {
    193             if (pawn)
    194             {
    195                 pawn->setRadarObjectColour(this->teamcolours_[it_player->second]);
    196 
    197                 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
    198                 for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
    199                 {
    200                     if ((*it)->isA(Class(TeamColourable)))
    201                     {
    202                         TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
    203                         tc->setTeamColour(this->teamcolours_[it_player->second]);
    204                     }
    205                 }
    206             }
     121            const std::string& message = player->getName() + " scores!";
     122            ChatManager::message(message);
    207123        }
    208124    }
    209125
    210     bool TeamDeathmatch::pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2)
    211     {
    212         if (pawn1 && pawn2)
    213         {
    214             std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
    215             std::map<PlayerInfo*, int>::const_iterator it2 = this->teamnumbers_.find(pawn2->getPlayer());
    216 
    217             if (it1 != this->teamnumbers_.end() && it2 != this->teamnumbers_.end())
    218                 return (it1->second == it2->second);
    219         }
    220         return false;
    221     }
    222 
    223     int TeamDeathmatch::getTeam(PlayerInfo* player)
    224     {
    225         std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
    226         if (it_player != this->teamnumbers_.end())
    227             return it_player->second;
    228         else
    229             return -1;
    230     }
    231126}
  • code/trunk/src/orxonox/gametypes/TeamDeathmatch.h

    r9016 r9348  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
    34 #include <map>
    35 #include <vector>
    36 #include "Deathmatch.h"
     33#include "TeamGametype.h"
    3734
    3835namespace orxonox
    3936{
    40     class _OrxonoxExport TeamDeathmatch : public Deathmatch
     37    class _OrxonoxExport TeamDeathmatch : public TeamGametype
    4138    {
    4239        public:
     
    4441            virtual ~TeamDeathmatch() {}
    4542
    46             void setConfigValues();
    47 
     43            virtual void start();
     44            virtual void end();
    4845            virtual void playerEntered(PlayerInfo* player);
    4946            virtual bool playerLeft(PlayerInfo* player);
     47            virtual bool playerChangedName(PlayerInfo* player);
    5048
    51             virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
    52             virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
    53             virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
    54 
    55             virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
    56 
    57             int getTeam(PlayerInfo* player);
    58             inline const ColourValue& getTeamColour(int teamnr) const
    59                 { return this->teamcolours_[teamnr]; }
    60 
    61         protected:
    62             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
    63             bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
    64 
    65             std::map<PlayerInfo*, int> teamnumbers_;
    66             std::vector<ColourValue> teamcolours_;
    67             unsigned int teams_;
     49            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     50            virtual void playerScored(PlayerInfo* player, int score = 1);
    6851    };
    6952}
  • code/trunk/src/orxonox/gametypes/TeamGametype.cc

    • Property svn:eol-style set to native
    r9048 r9348  
    8989    }
    9090
     91    /**
     92    @brief
     93        Function that determines the player's team number when entering the game for the first time.
     94        Override this function for other team structures.
     95    */
    9196    void TeamGametype::findAndSetTeam(PlayerInfo* player)
    9297    {
     
    130135            this->allowedInGame_.erase(player);
    131136        }
    132 
    133137
    134138        return valid_player;
  • code/trunk/src/orxonox/gametypes/TeamGametype.h

    • Property svn:eol-style set to native
  • code/trunk/src/orxonox/gametypes/UnderAttack.cc

    r9016 r9348  
    4949        this->gameEnded_ = false;
    5050
    51         //this->setHUDTemplate("UnderAttackHUD");
    52         //This HUD is in conflict with the HUDEnemyHealthBar
    5351        this->setConfigValues();
    5452        this->timesequence_ = static_cast<int>(this->gameTime_);
  • code/trunk/src/orxonox/infos/GametypeInfo.cc

    r9016 r9348  
    6868    {
    6969        RegisterObject(GametypeInfo);
    70        
     70
    7171        this->bStarted_ = false;
    7272        this->bEnded_ = false;
     
    165165        if(this->bStarted_)
    166166           { return;}
    167        
     167
    168168        this->bStarted_ = true;
    169169        this->changedStarted();
    170        
    171        
     170
     171
    172172    }
    173173
     
    195195        if(this->startCountdown_ == countdown || countdown < 0.0f)
    196196            return;
    197        
     197
    198198        this->startCountdown_ = countdown;
    199199        // Set the counter to the ceiling of the current countdown.
     
    225225        if(this->counter_ == 0)
    226226            return;
    227        
     227
    228228        this->counter_--;
    229229        this->changedCountdownCounter();
     
    325325        if(this->spawned_ == spawned)
    326326            return;
    327        
     327
    328328        this->spawned_ = spawned;
    329329        // Clear the notifications if the Player has spawned.
     
    395395    // TODO: Replace with notifications.
    396396
    397     void GametypeInfo::sendAnnounceMessage(const std::string& message)
     397    void GametypeInfo::sendAnnounceMessage(const std::string& message) const
    398398    {
    399399        if (GameMode::isMaster())
     
    404404    }
    405405
    406     void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID)
     406    void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const
    407407    {
    408408        if (GameMode::isMaster())
     
    415415    }
    416416
    417     void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID)
     417    void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const
    418418    {
    419419        if (GameMode::isMaster())
     
    426426    }
    427427
    428     void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID)
     428    void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const
    429429    {
    430430        if (GameMode::isMaster())
     
    437437    }
    438438
    439     void GametypeInfo::sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour)
     439    void GametypeInfo::sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour) const
    440440    {
    441441        if (GameMode::isMaster())
     
    448448    }
    449449
    450     void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID)
     450    void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID) const
    451451    {
    452452        if (GameMode::isMaster())
     
    459459    }
    460460
    461     void GametypeInfo::dispatchAnnounceMessage(const std::string& message)
     461    void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const
    462462    {
    463463        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     
    465465    }
    466466
    467     void GametypeInfo::dispatchKillMessage(const std::string& message)
     467    void GametypeInfo::dispatchKillMessage(const std::string& message) const
    468468    {
    469469        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     
    471471    }
    472472
    473     void GametypeInfo::dispatchDeathMessage(const std::string& message)
     473    void GametypeInfo::dispatchDeathMessage(const std::string& message) const
    474474    {
    475475        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     
    477477    }
    478478
    479      void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour)
     479     void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour) const
    480480    {
    481481        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     
    483483    }
    484484
    485      void GametypeInfo::dispatchFadingMessage(const std::string& message)
     485     void GametypeInfo::dispatchFadingMessage(const std::string& message) const
    486486    {
    487487        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
  • code/trunk/src/orxonox/infos/GametypeInfo.h

    r9016 r9348  
    6868                { return this->bStarted_; }
    6969            void changedStarted(void); // Is called when the game has changed to started.
    70            
     70
    7171            /**
    7272            @brief Get whether the game has ended yet.
     
    108108                { return this->readyToSpawn_; }
    109109            void changedReadyToSpawn(bool ready); // Inform the GametypeInfo that the local player has changed its spawned status.
    110            
     110
    111111            /**
    112112            @brief Get whether the local player is spawned.
     
    119119            inline const std::string& getHUDTemplate() const
    120120                { return this->hudtemplate_; }
    121            
    122             inline unsigned int getNumberOfPlayers() const
    123                 {  return this->spawnedPlayers_.size(); }
    124121
    125             void sendAnnounceMessage(const std::string& message);
    126             void sendAnnounceMessage(const std::string& message, unsigned int clientID);
    127             void sendKillMessage(const std::string& message, unsigned int clientID);
    128             void sendDeathMessage(const std::string& message, unsigned int clientID);
    129             void sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour);
    130             void sendFadingMessage(const std::string& message, unsigned int clientID);
     122            void sendAnnounceMessage(const std::string& message) const;
     123            void sendAnnounceMessage(const std::string& message, unsigned int clientID) const;
     124            void sendKillMessage(const std::string& message, unsigned int clientID) const;
     125            void sendDeathMessage(const std::string& message, unsigned int clientID) const;
     126            void sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour) const;
     127            void sendFadingMessage(const std::string& message, unsigned int clientID) const;
    131128
    132             void dispatchAnnounceMessage(const std::string& message);
    133             void dispatchKillMessage(const std::string& message);
    134             void dispatchDeathMessage(const std::string& message);
    135             void dispatchStaticMessage(const std::string& message,const ColourValue& colour);
    136             void dispatchFadingMessage(const std::string& message);
    137            
     129            void dispatchAnnounceMessage(const std::string& message) const;
     130            void dispatchKillMessage(const std::string& message) const;
     131            void dispatchDeathMessage(const std::string& message) const;
     132            void dispatchStaticMessage(const std::string& message,const ColourValue& colour) const;
     133            void dispatchFadingMessage(const std::string& message) const;
     134
    138135        protected:
    139136            void start(void); // Inform the GametypeInfo that the game has started.
     
    165162            unsigned int counter_; //!< The current integer value of the start countdown, the start countdown counter.
    166163            std::string hudtemplate_;
    167            
     164
    168165            std::set<PlayerInfo*> spawnedPlayers_; //!< A set of players that are currently spawned.
    169166            bool spawned_; //!< Whether the local Player is currently spawned.
  • code/trunk/src/orxonox/infos/PlayerInfo.cc

    r9257 r9348  
    173173        this->changedControllableEntity();
    174174
    175                 RadarViewable* radarviewable = orxonox_cast<RadarViewable*>(entity);
     175        RadarViewable* radarviewable = orxonox_cast<RadarViewable*>(entity);
    176176        if (radarviewable != NULL)
    177177            radarviewable->setRadarName(this->getName());
  • code/trunk/src/orxonox/interfaces/Pickupable.cc

    r8866 r9348  
    3939
    4040#include "infos/PlayerInfo.h"
    41 #include "pickup/PickupIdentifier.h"
    4241#include "worldentities/pawns/Pawn.h"
    4342
     
    5251        Constructor. Registers the objects and initializes its member variables.
    5352    */
    54     Pickupable::Pickupable() : pickupIdentifier_(NULL), used_(false), pickedUp_(false)
     53    Pickupable::Pickupable() : used_(false), pickedUp_(false)
    5554    {
    5655        RegisterRootObject(Pickupable);
     
    5857        this->carrier_ = NULL;
    5958
    60         this->pickupIdentifier_ = new PickupIdentifier(this);
    6159        this->beingDestroyed_ = false;
    6260        this->enabled_ = true;
     
    6967    Pickupable::~Pickupable()
    7068    {
    71         if(this->pickupIdentifier_ != NULL)
    72         {
    73             orxout(verbose, context::pickups) << "Pickupable (&" << this << ") destroyed." << endl;
    74             this->pickupIdentifier_->destroy();
    75         }
    7669    }
    7770
     
    10497    void Pickupable::destroyPickup(void)
    10598    {
    106         if(!this->beingDestroyed_)
     99        if(!this->isBeingDestroyed())
    107100            this->OrxonoxClass::destroy();
    108101        else
     
    329322    /**
    330323    @brief
    331         Creates a duplicate of the Pickupable.
    332     @return
    333         Returns the clone of this pickup as a pointer to a Pickupable.
    334     */
    335     Pickupable* Pickupable::clone(void)
    336     {
    337         OrxonoxClass* item = NULL;
    338         this->clone(item);
    339 
    340         Pickupable* pickup = dynamic_cast<Pickupable*>(item);
    341 
    342         orxout(verbose, context::pickups) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << endl;
    343         return pickup;
    344     }
    345 
    346     /**
    347     @brief
    348324        Method to transcribe a Pickupable as a Rewardable to the player.
    349325    @param player
  • code/trunk/src/orxonox/interfaces/Pickupable.h

    r8866 r9348  
    5353        Pickups (@ref orxonox::Pickupable "Pickupables") are objects that (quite unsurprisingly) can be picked up. Additionally they can be used and unused (transition from used to not used), and also dropped.
    5454
    55         A class of Pickups can incorporate many different types of pickups (see @ref orxonox::PickupIdentifier "PickupIdentifier"), each type is uniquely defined by a @ref orxonox::PickupIdentifier "PickupIdentifier". Each pickup has such an identifier identiying its type. This means that two pickups of the same type have identifiers which are equal.
    56 
    5755    @author
    5856        Damian 'Mozork' Frick
     
    6967        public:
    7068            virtual ~Pickupable(); //!< Default destructor.
     69
     70            //! @brief Returns the representation name which refers to the name of the PickupRepresentation that is used to represent this pickup.
     71            virtual const std::string& getRepresentationName() const = 0;
    7172
    7273            /**
     
    136137            bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this Pickupable.
    137138
    138             Pickupable* clone(void); //!< Creates a duplicate of the Pickupable.
    139             /**
    140             @brief Creates a duplicate of the input OrxonoxClass.
    141                    This method needs to be implemented by any Class inheriting from Pickupable.
    142             @param item A reference to a pointer to the OrxonoxClass that is to be duplicated.
    143             */
    144             virtual void clone(OrxonoxClass*& item) {}
    145 
    146             /**
    147             @brief Get the PickupIdentifier of this Pickupable.
    148             @return Returns a pointer to the PickupIdentifier of this Pickupable.
    149             */
    150             virtual const PickupIdentifier* getPickupIdentifier(void) const
    151                 { return this->pickupIdentifier_; }
    152 
    153139            bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input.
    154140            bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up.
     
    158144
    159145        protected:
    160             /**
    161             @brief Helper method to initialize the PickupIdentifier.
    162             */
    163             void initializeIdentifier(void) {}
    164 
    165146            virtual void preDestroy(void); //!< A method that is called by OrxonoxClass::destroy() before the object is actually destroyed.
    166147            virtual void destroyPickup(void); //!< Destroys a Pickupable.
     
    174155
    175156            /**
     157            @brief Check whether the Pickupable is in the process of being destroyed.
     158            @return Returns true if so.
     159            */
     160            inline bool isBeingDestroyed(void)
     161                { return this->beingDestroyed_; }
     162
     163            /**
    176164            @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    177                    This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
    178                    DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance);
     165                   This method must be implemented by any class directly inheriting from Pickupable.
    179166            @return Returns true if a spawner was created, false if not.
    180167            */
    181168            virtual bool createSpawner(void) = 0;
    182 
    183             PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.
    184169
    185170        private:
     
    203188    //! SUPER functions.
    204189    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
    205     SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
    206     SUPER_FUNCTION(13, Pickupable, changedPickedUp, false);
    207     SUPER_FUNCTION(11, Pickupable, clone, false);
     190    SUPER_FUNCTION(11, Pickupable, changedCarrier, false);
     191    SUPER_FUNCTION(12, Pickupable, changedPickedUp, false);
    208192}
    209193
  • code/trunk/src/orxonox/interfaces/RadarViewable.h

    r9257 r9348  
    6161        virtual ~RadarViewable();
    6262
    63                 virtual void setRadarName(const std::string& name)
    64                         {
    65                                 if (this->radarName_ != name)
    66                                 {
    67                                         this->radarName_ = name;
    68                                         this->settingsChanged();
    69                                 }
    70                         }
    71                 const std::string& getRadarName() const
    72                         { return this->radarName_; }
     63        virtual void setRadarName(const std::string& name)
     64            {
     65                if (this->radarName_ != name)
     66                {
     67                    this->radarName_ = name;
     68                    this->settingsChanged();
     69                }
     70            }
     71        const std::string& getRadarName() const
     72            { return this->radarName_; }
    7373
    7474        inline void setRadarObjectCamouflage(float camouflage)
     
    163163        ColourValue radarObjectColour_;
    164164        float scale_;
    165                 std::string radarName_;
     165        std::string radarName_;
    166166    };
    167167}
  • code/trunk/src/orxonox/worldentities/ControllableEntity.cc

    r9016 r9348  
    8787        this->setPriority( Priority::VeryHigh );
    8888        this->registerVariables();
    89         this->team_ = -1;
     89        this->team_ = -1;
    9090    }
    9191
     
    266266                this->cameraPositionRootNode_->_update(true, false); // update the camera node because otherwise the camera will drag back in position which looks strange
    267267
    268                 NewHumanController* controller = dynamic_cast<NewHumanController*>(this->getController());
     268                NewHumanController* controller = orxonox_cast<NewHumanController*>(this->getController());
    269269                if (controller)
    270270                    controller->centerCursor();
  • code/trunk/src/orxonox/worldentities/ControllableEntity.h

    r9255 r9348  
    164164            void setTargetInternal( uint32_t targetID );
    165165
    166             inline void setTeam(int team)
    167                 { this->team_ = team; }
    168             inline int getTeam() const
    169                 { return this->team_; }
     166            inline void setTeam(int team)
     167                { this->team_ = team; }
     168            inline int getTeam() const
     169                { return this->team_; }
    170170
    171171        protected:
     
    243243            WeakPtr<WorldEntity> target_;
    244244
    245             int team_ ; //<! teamnumber
     245            int team_ ; //<! teamnumber
    246246    };
    247247}
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r9257 r9348  
    7575        this->lastHitOriginator_ = 0;
    7676
     77        // set damage multiplier to default value 1, meaning nominal damage
     78        this->damageMultiplier_ = 1;
     79
    7780        this->spawnparticleduration_ = 3.0f;
    7881
     
    228231    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
    229232    {
     233        // Applies multiplier given by the DamageBoost Pickup.
     234        if (originator)
     235            damage *= originator->getDamageMultiplier();
     236
    230237        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    231238        {
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.h

    r9254 r9348  
    144144            virtual void addedWeaponPack(WeaponPack* wPack) {}
    145145
    146             inline const WorldEntity* getWorldEntity() const
    147                 { return const_cast<Pawn*>(this); }
    148 
    149146            inline void setSpawnParticleSource(const std::string& source)
    150147                { this->spawnparticlesource_ = source; }
     
    162159                { return this->numexplosionchunks_; }
    163160
     161            // These are used with the Damage Boost Pickup to use the damage multiplier.
     162            inline void setDamageMultiplier(float multiplier)
     163                { this->damageMultiplier_ = multiplier; }
     164            inline float getDamageMultiplier() const
     165                { return this->damageMultiplier_; }
     166
     167
    164168            virtual void startLocalHumanControl();
    165169
     
    203207            float maxShieldHealth_;
    204208            float initialShieldHealth_;
    205             float shieldAbsorption_; // Has to be between 0 and 1
     209            float shieldAbsorption_; ///< Has to be between 0 and 1
    206210            float reloadRate_;
    207211            float reloadWaitTime_;
    208212            float reloadWaitCountdown_;
     213
     214            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
    209215
    210216            WeakPtr<Pawn> lastHitOriginator_;
  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8892 r9348  
    133133    {
    134134        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
    135        
     135
    136136        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
    137137            .description("Enable or disable the motion blur effect when moving very fast")
     
    503503    void SpaceShip::resetCamera()
    504504    {
    505         if(this->hasLocalController() && this->hasHumanController())
    506         {
     505        if(this->hasLocalController() && this->hasHumanController())
     506        {
    507507            Camera *camera = this->getCamera();
    508508            if (camera == 0)
     
    514514            camera->setPosition(this->cameraOriginalPosition_);
    515515            camera->setOrientation(this->cameraOriginalOrientation_);
    516         }
     516        }
    517517    }
    518518
Note: See TracChangeset for help on using the changeset viewer.