Changeset 9348 for code/trunk/src/orxonox
- Timestamp:
- Aug 30, 2012, 11:08:17 PM (12 years ago)
- Location:
- code/trunk
- Files:
-
- 1 deleted
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 .project 1 2 build 2 3 codeblocks 4 dependencies 3 5 vs 4 dependencies
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
code/trunk/src/orxonox/CMakeLists.txt
r8858 r9348 50 50 ADD_SUBDIRECTORY(items) 51 51 ADD_SUBDIRECTORY(overlays) 52 ADD_SUBDIRECTORY(pickup)53 52 ADD_SUBDIRECTORY(sound) 54 53 ADD_SUBDIRECTORY(weaponsystem) -
code/trunk/src/orxonox/CameraManager.cc
r8079 r9348 48 48 CameraManager::CameraManager() 49 49 { 50 RegisterRootObject(CameraManager); 51 50 52 assert(GameMode::showsGraphics()); 51 53 } -
code/trunk/src/orxonox/LevelInfo.cc
r9016 r9348 42 42 43 43 // LevelInfoItem 44 44 45 45 //! The list of allowed tags. 46 46 /*static*/ std::set<std::string> LevelInfoItem::possibleTags_s = std::set<std::string>(); … … 93 93 LevelInfoItem::possibleTags_s.insert("gametype"); 94 94 LevelInfoItem::possibleTags_s.insert("minigame"); 95 LevelInfoItem::possibleTags_s.insert("shipselection"); 95 96 } 96 97 } … … 106 107 SubString substr = SubString(tags, ",", " "); // Split the string into tags. 107 108 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(); 108 124 for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++) 109 this->add Tag(*it, false);110 111 this-> tagsUpdated();125 this->addStartingShip(*it, false); 126 127 this->startingshipsUpdated(); 112 128 } 113 129 … … 137 153 /** 138 154 @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 139 175 Updates the comma-seperated string of all tags, if the set of tags has changed. 140 176 */ … … 155 191 } 156 192 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 157 242 // LevelInfo 158 243 … … 192 277 XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode); 193 278 XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode); 279 XMLPortParam(LevelInfo, "startingships", setStartingShips, getStartingShips, xmlelement, mode); 194 280 } 195 281 … … 207 293 info->setScreenshot(this->getScreenshot()); 208 294 info->setTags(this->getTags()); 295 info->setStartingShips(this->getStartingShips()); 209 296 return info; 210 297 } -
code/trunk/src/orxonox/LevelInfo.h
r9016 r9348 43 43 44 44 #include "core/BaseObject.h" 45 #include <iostream> 46 #include <fstream> 45 47 #include "core/OrxonoxClass.h" 46 48 … … 77 79 */ 78 80 inline const std::string& getName(void) const { return this->name_; } // tolua_export 79 81 80 82 /** 81 83 @brief Set the screenshot of the Level. … … 116 118 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 117 119 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 118 135 /** 119 136 @brief Get the XML-filename of the Level. … … 122 139 inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export 123 140 141 124 142 protected: 125 143 /** … … 133 151 134 152 private: 153 void changeStartingShip (const std::string& model); 154 void startingshipsUpdated(void); //!< Updates the comma-seperated string of all possible starting ships. 135 155 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 136 137 156 static void initializeTags(void); //!< Initialize the set of allowed tags. 138 157 /** … … 152 171 std::set<std::string> tags_; //!< The set of tags the Level is tagged with. 153 172 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. 154 175 }; // tolua_export 155 176 … … 161 182 - @b description The description of the level. 162 183 - @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 165 186 An example would be: 166 187 @code … … 176 197 @author 177 198 Damian 'Mozork' Frick 178 199 @edit 200 Matthias Hutter 179 201 @ingroup Orxonox 180 202 */ … … 186 208 187 209 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML. 188 210 189 211 /** 190 212 @brief Set the screenshot of the Level. … … 223 245 inline const std::string& getTags(void) const 224 246 { 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(); } 225 259 226 260 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 227 228 261 }; 229 262 … … 243 276 } 244 277 }; 245 278 246 279 } // tolua_export 247 280 -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r8858 r9348 109 109 class TeamDeathmatch; 110 110 class UnderAttack; 111 class TeamGametype; 111 112 112 113 // graphics … … 150 151 class OrxonoxOverlay; 151 152 class OverlayGroup; 152 153 // pickup154 class PickupIdentifier;155 153 156 154 //sound -
code/trunk/src/orxonox/Scene.cc
r8858 r9348 258 258 void Scene::setSkybox(const std::string& skybox) 259 259 { 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 } 262 270 263 271 this->skybox_ = skybox; -
code/trunk/src/orxonox/controllers/FormationController.cc
- Property svn:eol-style set to native
r9265 r9348 50 50 { 51 51 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 enemy66 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 { 73 73 RegisterObject(FormationController); 74 74 … … 91 91 this->team_=-1; 92 92 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()) 98 98 { 99 99 this->removeFromFormation(); … … 123 123 } 124 124 } 125 }126 127 void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)125 } 126 127 void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode) 128 128 { 129 129 SUPER(FormationController, XMLPort, xmlelement, mode); … … 137 137 138 138 139 /**139 /** 140 140 @brief Activates / deactivates formationflight behaviour 141 141 @param form activate formflight if form is true 142 142 */ 143 void FormationController::formationflight(const bool form)143 void FormationController::formationflight(const bool form) 144 144 { 145 145 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it) … … 168 168 } 169 169 170 /**170 /** 171 171 @brief Get all masters to do a "specific master action" 172 172 @param action which action to perform (integer, so it can be called with a console command (tmp solution)) … … 198 198 } 199 199 200 /**200 /** 201 201 @brief Sets shooting behaviour of pawns. 202 202 @param passive if true, bots won't shoot. … … 225 225 } 226 226 227 /**227 /** 228 228 @brief Sets maximal formation size 229 229 @param size maximal formation size. … … 280 280 } 281 281 282 Vector2 coord = get2DView direction(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); 283 283 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); 285 286 286 287 if(this->state_ == FREE) … … 289 290 { 290 291 // 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()) 296 297 { 297 298 this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance … … 305 306 if (this->target_ || distance > 10) 306 307 { 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); 309 310 } 310 311 … … 320 321 { 321 322 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); 324 325 325 326 if (distance < 300) 326 327 { 327 328 329 330 328 if (bHasTargetOrientation_) 329 { 330 copyTargetOrientation(); 331 } 331 332 if (distance < 100) 332 { 333 { //linear speed reduction 333 334 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 338 340 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f); 339 }340 341 } 341 342 … … 343 344 { 344 345 this->positionReached(); 345 346 } 347 } 348 349 350 351 void FormationController::moveToTargetPosition()346 bHasTargetOrientation_=false; 347 } 348 } 349 350 351 352 void FormationController::moveToTargetPosition() 352 353 { 353 354 this->moveToPosition(this->targetPosition_); 354 355 } 355 356 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) 358 359 { 359 360 //roll angle difference in radian … … 373 374 374 375 375 /**376 /** 376 377 @brief Unregisters a slave from its master. Initiated by a slave. 377 378 */ … … 463 464 } 464 465 } 465 /** 466 467 /** 466 468 @brief Commands the slaves of a master into a formation. Sufficiently fast not to be called within tick. Initiated by a master. 467 469 */ 468 469 void FormationController::commandSlaves() 470 void FormationController::commandSlaves() 470 471 { 471 472 if(this->state_ != MASTER) return; … … 481 482 } 482 483 else 483 484 // formation: 484 485 { 485 486 dest += 1.0f*orient*WorldEntity::BACK; 486 487 Vector3 pos = Vector3::ZERO; 487 488 bool left=true; 488 489 int i = 1; 489 490 … … 683 684 684 685 if (specificMasterActionHoldCount_ == 0) 685 686 { 686 687 this->specificMasterAction_ = NONE; 687 688 this->searchNewTarget(); 688 } 689 else specificMasterActionHoldCount_--; 689 } 690 else 691 specificMasterActionHoldCount_--; 690 692 } 691 693 … … 711 713 void FormationController::turn180() 712 714 { 713 714 715 716 717 718 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); 719 721 } 720 722 … … 734 736 void FormationController::spin() 735 737 { 736 737 738 this->moveToTargetPosition(); 739 this->getControllableEntity()->rotateRoll(0.8f); 738 740 } 739 741 … … 773 775 if((humanPawn != NULL) && (allMasters.size() != 0)) 774 776 { 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 } 795 792 796 793 /** … … 814 811 } 815 812 816 /**813 /** 817 814 @brief Master begins to follow a randomly chosen human player of the same team. Is a "specific master action". 818 815 */ … … 842 839 843 840 844 /**841 /** 845 842 @brief Master follows target with adjusted speed. Called within tick. 846 843 */ … … 854 851 855 852 856 void FormationController::setTargetPosition(const Vector3& target)853 void FormationController::setTargetPosition(const Vector3& target) 857 854 { 858 855 this->targetPosition_ = target; … … 918 915 } 919 916 920 void FormationController::forgetTarget()917 void FormationController::forgetTarget() 921 918 { 922 919 this->target_ = 0; … … 924 921 } 925 922 926 void FormationController::targetDied()923 void FormationController::targetDied() 927 924 { 928 925 this->forgetTarget(); … … 930 927 } 931 928 932 bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)929 bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 933 930 { 934 931 if (entity1 == entity2) … … 1054 1051 return; 1055 1052 1056 Vector2 coord = get2DView direction(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); 1057 1054 float distance = (target - this->getControllableEntity()->getPosition()).length(); 1058 1055 … … 1060 1057 { 1061 1058 // 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)); 1064 1061 this->getControllableEntity()->moveFrontBack(SPEED_FREE); 1065 1062 } -
code/trunk/src/orxonox/controllers/FormationController.h
- Property svn:eol-style set to native
-
code/trunk/src/orxonox/controllers/NewHumanController.cc
r9016 r9348 298 298 //Used in HumanController for formationFlight 299 299 HumanController::hit(originator,contactpoint,damage); 300 300 301 301 if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook()) 302 302 { … … 397 397 try 398 398 { 399 wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));399 wePtr = orxonox_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny())); 400 400 } 401 401 catch (...) -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r8858 r9348 76 76 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it) 77 77 { 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; 80 81 else 81 82 orxout(debug_output) << "object: " << it->getIdentifier()->getName() << endl; -
code/trunk/src/orxonox/gametypes/Deathmatch.cc
r8858 r9348 114 114 } 115 115 116 void Deathmatch::playerScored(PlayerInfo* player )116 void Deathmatch::playerScored(PlayerInfo* player, int score) 117 117 { 118 Gametype::playerScored(player );118 Gametype::playerScored(player, score); 119 119 120 120 if (player) -
code/trunk/src/orxonox/gametypes/Deathmatch.h
r5781 r9348 48 48 49 49 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 50 virtual void playerScored(PlayerInfo* player );50 virtual void playerScored(PlayerInfo* player, int score = 1); 51 51 }; 52 52 } -
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r8858 r9348 31 31 //Low; Codeoptimierung und Dokumentation 32 32 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. 45 46 */ 46 47 #include "Dynamicmatch.h" … … 81 82 this->numberOf[killer]=0; 82 83 this->tutorial=true; 83 this->pointsPerTime= 0.0f;84 this->pointsPerTime=1.0f; 84 85 this->setHUDTemplate("DynamicmatchHUD"); 85 86 } … … 95 96 ColourValue(0.3f, 0.3f, 1.0f), //piggycolour 96 97 ColourValue(0.3f, 1.0f, 0.3f) //killercolour what about black: 0.0f, 0.0f, 0.0f 97 98 98 }; 99 99 static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue)); … … 111 111 if (victim && victim->getPlayer()) //&& originator && originator->getPlayer() ?? 112 112 { 113 int target= playerParty_[victim->getPlayer()];114 int source= playerParty_[originator->getPlayer()];113 int target = playerParty_[victim->getPlayer()]; 114 int source = playerParty_[originator->getPlayer()]; 115 115 116 116 //Case: Not Enough Pigs: party change (= party management) … … 151 151 152 152 //Give new pig boost 153 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);153 SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim); 154 154 this->grantPigBoost(spaceship); 155 155 } … … 245 245 } 246 246 //Give new pig boost 247 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);247 SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim); 248 248 this->grantPigBoost(spaceship); 249 249 } … … 276 276 else if (friendlyfire && (source == target)) 277 277 { 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 } 285 281 return false; //default: no damage 286 282 } … … 296 292 if (playerParty_[originator->getPlayer()] == killer) //reward the killer 297 293 { 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; 305 297 } 306 298 else return false; … … 309 301 /** 310 302 @brief 311 Grant the piggya boost.303 Grant the victim a boost. 312 304 @param spaceship 313 305 The SpaceShip to give the boost. … … 315 307 void Dynamicmatch::grantPigBoost(SpaceShip* spaceship) 316 308 { 317 // Give pigboost309 // Give victim boost 318 310 if (spaceship) 319 311 { 312 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship); 313 if(ptr == NULL) 314 return; 320 315 spaceship->addSpeedFactor(5); 321 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);322 316 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 323 317 executor->setDefaultValue(0, ptr); … … 374 368 375 369 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; 381 376 rewardPig(); 382 377 } … … 408 403 } 409 404 405 /** 406 @brief The reward function is called every 2 seconds via the tick function and makes the victim score points. 407 */ 410 408 void Dynamicmatch::rewardPig() 411 409 { 412 410 for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden 413 411 { 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); 422 415 } 423 416 } … … 426 419 { 427 420 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()); 429 422 if (pawn) 430 423 { … … 446 439 { 447 440 //pigs: 1 + every 6th player is a pig 448 if ( (1 +this->getNumberOfPlayers()/6) > numberOf[piggy])441 if ( (1 + getPlayerCount()/6) > numberOf[piggy]) 449 442 { 450 443 notEnoughPigs=true; … … 495 488 } 496 489 //killers: every 4th player is a killer 497 if ( getNumberOfPlayers()/4> numberOf[killer])490 if ( static_cast<unsigned int>(getPlayerCount()/4) > numberOf[killer]) 498 491 { 499 492 notEnoughKillers=true; -
code/trunk/src/orxonox/gametypes/Dynamicmatch.h
r8727 r9348 81 81 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; 82 82 83 83 84 protected: 85 inline int getPlayerCount() const 86 { return this->numberOf[chaser] + numberOf[piggy] + this->numberOf[killer]; } 84 87 85 88 std::map< PlayerInfo*, int > playerParty_; //player's parties are recorded here -
code/trunk/src/orxonox/gametypes/Gametype.cc
r9261 r9348 301 301 } 302 302 303 void Gametype::playerScored(PlayerInfo* player )303 void Gametype::playerScored(PlayerInfo* player, int score) 304 304 { 305 305 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 306 306 if (it != this->players_.end()) 307 it->second.frags_ ++;307 it->second.frags_ += score; 308 308 } 309 309 -
code/trunk/src/orxonox/gametypes/Gametype.h
r9260 r9348 90 90 virtual bool playerChangedName(PlayerInfo* player); 91 91 92 virtual void playerScored(PlayerInfo* player );92 virtual void playerScored(PlayerInfo* player, int score = 1); 93 93 94 94 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0); … … 153 153 virtual void resetTimer(float t); 154 154 155 /** 156 @brief Get number of Players in game. 157 */ 155 158 inline unsigned int getNumberOfPlayers() const 156 { return this->gtinfo_->getNumberOfPlayers(); } 159 { return this->players_.size(); } 160 161 157 162 158 163 protected: -
code/trunk/src/orxonox/gametypes/LastManStanding.cc
r8858 r9348 211 211 if(!player->getControllableEntity()) 212 212 return; 213 Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());213 Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity()); 214 214 if(!pawn) 215 215 return; -
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
r8858 r9348 283 283 if(!player->getControllableEntity()) 284 284 return; 285 Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());285 Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity()); 286 286 if(!pawn) 287 287 return; -
code/trunk/src/orxonox/gametypes/Mission.cc
- Property svn:eol-style set to native
r9016 r9348 63 63 { 64 64 this->missionAccomplished_ = false; 65 65 this->end(); 66 66 } 67 67 } … … 78 78 { 79 79 Gametype::end(); 80 /*if (this->missionAccomplished_) 80 /*if (this->missionAccomplished_) 81 81 this->gtinfo_->sendAnnounceMessage("Mission accomplished!"); 82 82 else 83 83 this->gtinfo_->sendAnnounceMessage("Mission failed!"); 84 **/84 */ 85 85 } 86 86 -
code/trunk/src/orxonox/gametypes/Mission.h
- Property svn:eol-style set to native
-
code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
r8952 r9348 128 128 129 129 // collect Points for killing oppenents 130 void TeamBaseMatch::playerScored(PlayerInfo* player )130 void TeamBaseMatch::playerScored(PlayerInfo* player, int score) 131 131 { 132 132 int teamnr = this->getTeam(player); -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.h
r5929 r9348 47 47 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator); 48 48 49 virtual void playerScored(PlayerInfo* player );49 virtual void playerScored(PlayerInfo* player, int score = 1); 50 50 virtual void showPoints(); 51 51 virtual void endGame(); -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r7182 r9348 30 30 31 31 #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" 35 34 #include "worldentities/pawns/Pawn.h" 36 35 … … 39 38 CreateUnloadableFactory(TeamDeathmatch); 40 39 41 TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : Deathmatch(creator)40 TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : TeamGametype(creator) 42 41 { 43 42 RegisterObject(TeamDeathmatch); 44 45 this->teams_ = 2;46 47 this->setConfigValues();48 43 } 49 44 50 void TeamDeathmatch::s etConfigValues()45 void TeamDeathmatch::start() 51 46 { 52 SetConfigValue(teams_, 2);47 TeamGametype::start(); 53 48 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 } 62 52 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); 64 59 } 65 60 66 61 void TeamDeathmatch::playerEntered(PlayerInfo* player) 67 62 { 68 Deathmatch::playerEntered(player);63 TeamGametype::playerEntered(player); 69 64 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); 88 67 } 89 68 90 69 bool TeamDeathmatch::playerLeft(PlayerInfo* player) 91 70 { 92 bool valid_player = Deathmatch::playerLeft(player);71 bool valid_player = TeamGametype::playerLeft(player); 93 72 94 73 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 } 96 90 97 91 return valid_player; 98 92 } 99 93 100 bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator)94 void TeamDeathmatch::pawnKilled(Pawn* victim, Pawn* killer) 101 95 { 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); 103 113 } 104 114 105 bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator)115 void TeamDeathmatch::playerScored(PlayerInfo* player, int score) 106 116 { 107 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 108 } 117 TeamGametype::playerScored(player, score); 109 118 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) 125 120 { 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); 207 123 } 208 124 } 209 125 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 else229 return -1;230 }231 126 } -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.h
r9016 r9348 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include <map> 35 #include <vector> 36 #include "Deathmatch.h" 33 #include "TeamGametype.h" 37 34 38 35 namespace orxonox 39 36 { 40 class _OrxonoxExport TeamDeathmatch : public Deathmatch37 class _OrxonoxExport TeamDeathmatch : public TeamGametype 41 38 { 42 39 public: … … 44 41 virtual ~TeamDeathmatch() {} 45 42 46 v oid setConfigValues();47 43 virtual void start(); 44 virtual void end(); 48 45 virtual void playerEntered(PlayerInfo* player); 49 46 virtual bool playerLeft(PlayerInfo* player); 47 virtual bool playerChangedName(PlayerInfo* player); 50 48 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); 68 51 }; 69 52 } -
code/trunk/src/orxonox/gametypes/TeamGametype.cc
- Property svn:eol-style set to native
r9048 r9348 89 89 } 90 90 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 */ 91 96 void TeamGametype::findAndSetTeam(PlayerInfo* player) 92 97 { … … 130 135 this->allowedInGame_.erase(player); 131 136 } 132 133 137 134 138 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 49 49 this->gameEnded_ = false; 50 50 51 //this->setHUDTemplate("UnderAttackHUD");52 //This HUD is in conflict with the HUDEnemyHealthBar53 51 this->setConfigValues(); 54 52 this->timesequence_ = static_cast<int>(this->gameTime_); -
code/trunk/src/orxonox/infos/GametypeInfo.cc
r9016 r9348 68 68 { 69 69 RegisterObject(GametypeInfo); 70 70 71 71 this->bStarted_ = false; 72 72 this->bEnded_ = false; … … 165 165 if(this->bStarted_) 166 166 { return;} 167 167 168 168 this->bStarted_ = true; 169 169 this->changedStarted(); 170 171 170 171 172 172 } 173 173 … … 195 195 if(this->startCountdown_ == countdown || countdown < 0.0f) 196 196 return; 197 197 198 198 this->startCountdown_ = countdown; 199 199 // Set the counter to the ceiling of the current countdown. … … 225 225 if(this->counter_ == 0) 226 226 return; 227 227 228 228 this->counter_--; 229 229 this->changedCountdownCounter(); … … 325 325 if(this->spawned_ == spawned) 326 326 return; 327 327 328 328 this->spawned_ = spawned; 329 329 // Clear the notifications if the Player has spawned. … … 395 395 // TODO: Replace with notifications. 396 396 397 void GametypeInfo::sendAnnounceMessage(const std::string& message) 397 void GametypeInfo::sendAnnounceMessage(const std::string& message) const 398 398 { 399 399 if (GameMode::isMaster()) … … 404 404 } 405 405 406 void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) 406 void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const 407 407 { 408 408 if (GameMode::isMaster()) … … 415 415 } 416 416 417 void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) 417 void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const 418 418 { 419 419 if (GameMode::isMaster()) … … 426 426 } 427 427 428 void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) 428 void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const 429 429 { 430 430 if (GameMode::isMaster()) … … 437 437 } 438 438 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 440 440 { 441 441 if (GameMode::isMaster()) … … 448 448 } 449 449 450 void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID) 450 void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID) const 451 451 { 452 452 if (GameMode::isMaster()) … … 459 459 } 460 460 461 void GametypeInfo::dispatchAnnounceMessage(const std::string& message) 461 void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const 462 462 { 463 463 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) … … 465 465 } 466 466 467 void GametypeInfo::dispatchKillMessage(const std::string& message) 467 void GametypeInfo::dispatchKillMessage(const std::string& message) const 468 468 { 469 469 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) … … 471 471 } 472 472 473 void GametypeInfo::dispatchDeathMessage(const std::string& message) 473 void GametypeInfo::dispatchDeathMessage(const std::string& message) const 474 474 { 475 475 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) … … 477 477 } 478 478 479 void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour) 479 void GametypeInfo::dispatchStaticMessage(const std::string& message, const ColourValue& colour) const 480 480 { 481 481 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) … … 483 483 } 484 484 485 void GametypeInfo::dispatchFadingMessage(const std::string& message) 485 void GametypeInfo::dispatchFadingMessage(const std::string& message) const 486 486 { 487 487 for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it) -
code/trunk/src/orxonox/infos/GametypeInfo.h
r9016 r9348 68 68 { return this->bStarted_; } 69 69 void changedStarted(void); // Is called when the game has changed to started. 70 70 71 71 /** 72 72 @brief Get whether the game has ended yet. … … 108 108 { return this->readyToSpawn_; } 109 109 void changedReadyToSpawn(bool ready); // Inform the GametypeInfo that the local player has changed its spawned status. 110 110 111 111 /** 112 112 @brief Get whether the local player is spawned. … … 119 119 inline const std::string& getHUDTemplate() const 120 120 { return this->hudtemplate_; } 121 122 inline unsigned int getNumberOfPlayers() const123 { return this->spawnedPlayers_.size(); }124 121 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; 131 128 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 138 135 protected: 139 136 void start(void); // Inform the GametypeInfo that the game has started. … … 165 162 unsigned int counter_; //!< The current integer value of the start countdown, the start countdown counter. 166 163 std::string hudtemplate_; 167 164 168 165 std::set<PlayerInfo*> spawnedPlayers_; //!< A set of players that are currently spawned. 169 166 bool spawned_; //!< Whether the local Player is currently spawned. -
code/trunk/src/orxonox/infos/PlayerInfo.cc
r9257 r9348 173 173 this->changedControllableEntity(); 174 174 175 175 RadarViewable* radarviewable = orxonox_cast<RadarViewable*>(entity); 176 176 if (radarviewable != NULL) 177 177 radarviewable->setRadarName(this->getName()); -
code/trunk/src/orxonox/interfaces/Pickupable.cc
r8866 r9348 39 39 40 40 #include "infos/PlayerInfo.h" 41 #include "pickup/PickupIdentifier.h"42 41 #include "worldentities/pawns/Pawn.h" 43 42 … … 52 51 Constructor. Registers the objects and initializes its member variables. 53 52 */ 54 Pickupable::Pickupable() : pickupIdentifier_(NULL),used_(false), pickedUp_(false)53 Pickupable::Pickupable() : used_(false), pickedUp_(false) 55 54 { 56 55 RegisterRootObject(Pickupable); … … 58 57 this->carrier_ = NULL; 59 58 60 this->pickupIdentifier_ = new PickupIdentifier(this);61 59 this->beingDestroyed_ = false; 62 60 this->enabled_ = true; … … 69 67 Pickupable::~Pickupable() 70 68 { 71 if(this->pickupIdentifier_ != NULL)72 {73 orxout(verbose, context::pickups) << "Pickupable (&" << this << ") destroyed." << endl;74 this->pickupIdentifier_->destroy();75 }76 69 } 77 70 … … 104 97 void Pickupable::destroyPickup(void) 105 98 { 106 if(!this-> beingDestroyed_)99 if(!this->isBeingDestroyed()) 107 100 this->OrxonoxClass::destroy(); 108 101 else … … 329 322 /** 330 323 @brief 331 Creates a duplicate of the Pickupable.332 @return333 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 @brief348 324 Method to transcribe a Pickupable as a Rewardable to the player. 349 325 @param player -
code/trunk/src/orxonox/interfaces/Pickupable.h
r8866 r9348 53 53 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. 54 54 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 57 55 @author 58 56 Damian 'Mozork' Frick … … 69 67 public: 70 68 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; 71 72 72 73 /** … … 136 137 bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this Pickupable. 137 138 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) const151 { return this->pickupIdentifier_; }152 153 139 bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input. 154 140 bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up. … … 158 144 159 145 protected: 160 /**161 @brief Helper method to initialize the PickupIdentifier.162 */163 void initializeIdentifier(void) {}164 165 146 virtual void preDestroy(void); //!< A method that is called by OrxonoxClass::destroy() before the object is actually destroyed. 166 147 virtual void destroyPickup(void); //!< Destroys a Pickupable. … … 174 155 175 156 /** 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 /** 176 164 @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. 179 166 @return Returns true if a spawner was created, false if not. 180 167 */ 181 168 virtual bool createSpawner(void) = 0; 182 183 PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.184 169 185 170 private: … … 203 188 //! SUPER functions. 204 189 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); 208 192 } 209 193 -
code/trunk/src/orxonox/interfaces/RadarViewable.h
r9257 r9348 61 61 virtual ~RadarViewable(); 62 62 63 64 65 66 67 68 69 70 71 72 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_; } 73 73 74 74 inline void setRadarObjectCamouflage(float camouflage) … … 163 163 ColourValue radarObjectColour_; 164 164 float scale_; 165 165 std::string radarName_; 166 166 }; 167 167 } -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r9016 r9348 87 87 this->setPriority( Priority::VeryHigh ); 88 88 this->registerVariables(); 89 89 this->team_ = -1; 90 90 } 91 91 … … 266 266 this->cameraPositionRootNode_->_update(true, false); // update the camera node because otherwise the camera will drag back in position which looks strange 267 267 268 NewHumanController* controller = dynamic_cast<NewHumanController*>(this->getController());268 NewHumanController* controller = orxonox_cast<NewHumanController*>(this->getController()); 269 269 if (controller) 270 270 controller->centerCursor(); -
code/trunk/src/orxonox/worldentities/ControllableEntity.h
r9255 r9348 164 164 void setTargetInternal( uint32_t targetID ); 165 165 166 167 168 169 166 inline void setTeam(int team) 167 { this->team_ = team; } 168 inline int getTeam() const 169 { return this->team_; } 170 170 171 171 protected: … … 243 243 WeakPtr<WorldEntity> target_; 244 244 245 245 int team_ ; //<! teamnumber 246 246 }; 247 247 } -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r9257 r9348 75 75 this->lastHitOriginator_ = 0; 76 76 77 // set damage multiplier to default value 1, meaning nominal damage 78 this->damageMultiplier_ = 1; 79 77 80 this->spawnparticleduration_ = 3.0f; 78 81 … … 228 231 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 229 232 { 233 // Applies multiplier given by the DamageBoost Pickup. 234 if (originator) 235 damage *= originator->getDamageMultiplier(); 236 230 237 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 231 238 { -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r9254 r9348 144 144 virtual void addedWeaponPack(WeaponPack* wPack) {} 145 145 146 inline const WorldEntity* getWorldEntity() const147 { return const_cast<Pawn*>(this); }148 149 146 inline void setSpawnParticleSource(const std::string& source) 150 147 { this->spawnparticlesource_ = source; } … … 162 159 { return this->numexplosionchunks_; } 163 160 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 164 168 virtual void startLocalHumanControl(); 165 169 … … 203 207 float maxShieldHealth_; 204 208 float initialShieldHealth_; 205 float shieldAbsorption_; // Has to be between 0 and 1209 float shieldAbsorption_; ///< Has to be between 0 and 1 206 210 float reloadRate_; 207 211 float reloadWaitTime_; 208 212 float reloadWaitCountdown_; 213 214 float damageMultiplier_; ///< Used by the Damage Boost Pickup. 209 215 210 216 WeakPtr<Pawn> lastHitOriginator_; -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r8892 r9348 133 133 { 134 134 SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down)."); 135 135 136 136 SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true) 137 137 .description("Enable or disable the motion blur effect when moving very fast") … … 503 503 void SpaceShip::resetCamera() 504 504 { 505 506 505 if(this->hasLocalController() && this->hasHumanController()) 506 { 507 507 Camera *camera = this->getCamera(); 508 508 if (camera == 0) … … 514 514 camera->setPosition(this->cameraOriginalPosition_); 515 515 camera->setOrientation(this->cameraOriginalOrientation_); 516 516 } 517 517 } 518 518
Note: See TracChangeset
for help on using the changeset viewer.