Changeset 9272 for code/branches/presentation2012merge/src/orxonox
- Timestamp:
- Jun 3, 2012, 6:05:24 PM (13 years ago)
- Location:
- code/branches/presentation2012merge/src/orxonox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/orxonox/LevelInfo.h
r9269 r9272 24 24 * Co-authors: 25 25 * ... 26 * 26 * 27 27 */ 28 28 … … 79 79 */ 80 80 inline const std::string& getName(void) const { return this->name_; } // tolua_export 81 81 82 82 /** 83 83 @brief Set the screenshot of the Level. … … 117 117 */ 118 118 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 119 119 120 120 void setShips(const std::string& ships); //!< Set the starting ship models of the level 121 121 bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection … … 125 125 */ 126 126 inline const std::string& getShips(void) const 127 { return this->startingShipsString_; } 127 { return this->startingShipsString_; } 128 128 /** 129 129 @brief Get whether the Level allows a specific starting ship model … … 131 131 @return Returns true if the Level allows the input ship model 132 132 */ 133 inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export 133 inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export 134 134 /** 135 135 @brief Get the XML-filename of the Level. … … 138 138 139 139 inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export 140 140 inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export 141 141 142 142 … … 153 153 private: 154 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 172 if (found!= std::string::npos) 173 174 175 176 177 178 179 180 } 155 inline void changeShip (const std::string& model) { 156 static std::string shipSelectionTag = "shipselection"; 157 //HACK: Read Level XML File, find "shipselection", replace with ship model 158 std::string levelPath = "../levels/"; 159 levelPath.append(this->getXMLFilename()); 160 std::string tempPath = "../levels/"; 161 tempPath.append("_temp.oxw"); 162 orxout(user_status) << levelPath << endl; 163 orxout(user_status) << tempPath << endl; 164 std::ifstream myLevel (levelPath.c_str()); 165 std::ofstream tempLevel (tempPath.c_str()); 166 while(!myLevel.eof()) 167 { 168 std::string buff; 169 std::getline(myLevel, buff); 170 std::string pawndesignString = "pawndesign="; 171 size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 172 if (found!= std::string::npos) 173 buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos); 174 tempLevel.write(buff.c_str(), buff.length()); 175 tempLevel << std::endl; 176 } 177 myLevel.close(); 178 tempLevel.close(); 179 orxout(user_status) << "done" << endl; 180 } 181 181 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 182 182 void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. … … 199 199 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 200 200 std::set<std::string> ships_; //!< The set of starting ship models the Level allows. 201 std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection. 201 std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection. 202 202 }; // tolua_export 203 203 … … 210 210 - @b screenshot The screenshot of the level. 211 211 - @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>. 212 - @b (optional) startingships The comma-seperated string of starting ship models 212 - @b (optional) startingships The comma-seperated string of starting ship models 213 213 An example would be: 214 214 @code … … 224 224 @author 225 225 Damian 'Mozork' Frick 226 227 226 @edit 227 Matthias Hutter 228 228 @ingroup Orxonox 229 229 */ … … 235 235 236 236 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML. 237 237 238 238 /** 239 239 @brief Set the screenshot of the Level. … … 283 283 */ 284 284 inline const std::string& getShips(void) const 285 { return this->LevelInfoItem::getShips(); } 285 { return this->LevelInfoItem::getShips(); } 286 286 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 287 287 }; … … 302 302 } 303 303 }; 304 304 305 305 } // tolua_export 306 306 -
code/branches/presentation2012merge/src/orxonox/ShipManager.cc
r9271 r9272 22 22 * Author: 23 23 * Matthias Hutter 24 * 24 * 25 25 */ 26 26 … … 28 28 @file ShipManager.cc 29 29 @brief Work-in Progress: Implementation of the ShipManager singleton. 30 30 Should make SpaceShip info available to lua handlers. 31 31 */ 32 32 … … 72 72 } 73 73 74 74 75 75 /** 76 76 @brief … … 132 132 void ShipManager::compileAvailableShipList() 133 133 { 134 135 136 137 138 139 140 141 142 143 144 145 146 147 134 /* 135 // We only want to load as little as possible 136 ClassTreeMask mask; 137 mask.exclude(Class(BaseObject)); 138 mask.include(Class(SpaceShip)); 139 SpaceShip* info = NULL; 140 XMLFile file = XMLFile(ship); 141 Loader::load(&file, mask, false, true); 142 for(ObjectList<SpaceShip>::iterator item = ObjectList<SpaceShip>::begin(); item != ObjectList<SpaceShip>::end(); ++item) 143 if(item->getXMLFilename() == *it) 144 info = item->copy(); 145 Loader::unload(&file); 146 */ 147 148 148 // Get all files matching the level criteria 149 149 Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw"); -
code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc
r9271 r9272 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. … … 282 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 285 286 287 288 289 290 284 if(coord.x < 0.0001 && coord.y < 0.0001) 285 { 286 // if the ship reaches a direction very close to the direct one, set it to the direct one 287 Vector3 v_temp = this->getControllableEntity()->getPosition(); 288 Quaternion quat = v_temp.getRotationTo(target); 289 this->getControllableEntity()->rotate(quat); 290 } 291 291 292 292 if(this->state_ == FREE) … … 324 324 325 325 if(this->state_ == SLAVE) 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); 342 343 } else { 344 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f); 345 } 346 326 { 327 328 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2); 329 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2); 330 331 if (distance < 300) 332 { 333 if (bHasTargetOrientation_) 334 { 335 copyTargetOrientation(); 336 } 337 if (distance < 100) 338 { //linear speed reduction 339 this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER); 340 } 341 else 342 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); 343 } 344 else 345 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f); 346 } 347 347 348 348 if (distance < 10) 349 349 { 350 350 this->positionReached(); 351 352 } 353 } 354 355 356 357 void FormationController::moveToTargetPosition()351 bHasTargetOrientation_=false; 352 } 353 } 354 355 356 357 void FormationController::moveToTargetPosition() 358 358 { 359 359 this->moveToPosition(this->targetPosition_); 360 360 } 361 361 362 //copy the Roll orientation of given Quaternion.363 void FormationController::copyOrientation(const Quaternion& orient)362 //copy the Roll orientation of given Quaternion. 363 void FormationController::copyOrientation(const Quaternion& orient) 364 364 { 365 365 //roll angle difference in radian … … 379 379 380 380 381 /**381 /** 382 382 @brief Unregisters a slave from its master. Initiated by a slave. 383 383 */ … … 469 469 } 470 470 } 471 /** 471 472 /** 472 473 @brief Commands the slaves of a master into a formation. Sufficiently fast not to be called within tick. Initiated by a master. 473 474 */ 474 475 void FormationController::commandSlaves() 475 void FormationController::commandSlaves() 476 476 { 477 477 if(this->state_ != MASTER) return; … … 487 487 } 488 488 else 489 489 // formation: 490 490 { 491 491 dest += 1.0f*orient*WorldEntity::BACK; 492 492 Vector3 pos = Vector3::ZERO; 493 493 bool left=true; 494 494 int i = 1; 495 495 … … 689 689 690 690 if (specificMasterActionHoldCount_ == 0) 691 691 { 692 692 this->specificMasterAction_ = NONE; 693 693 this->searchNewTarget(); 694 } 695 else specificMasterActionHoldCount_--; 694 } 695 else 696 specificMasterActionHoldCount_--; 696 697 } 697 698 … … 717 718 void FormationController::turn180() 718 719 { 719 720 721 722 723 724 720 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_); 721 722 this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x); 723 this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y); 724 725 this->getControllableEntity()->moveFrontBack(SPEED_MASTER); 725 726 } 726 727 … … 740 741 void FormationController::spin() 741 742 { 742 743 743 this->moveToTargetPosition(); 744 this->getControllableEntity()->rotateRoll(0.8f); 744 745 } 745 746 … … 779 780 if((humanPawn != NULL) && (allMasters.size() != 0)) 780 781 { 781 float posHuman = humanPawn->getPosition().length(); 782 float distance = 0.0f; 783 float minDistance = FLT_MAX; 784 int index = 0; 785 int i = 0; 786 787 for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++) 788 { 789 if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue; 790 distance = posHuman - (*it)->getControllableEntity()->getPosition().length(); 791 if(distance < minDistance) index = i; 792 } 793 allMasters[index]->followInit(humanPawn); 794 } 795 796 } 797 798 799 800 782 float posHuman = humanPawn->getPosition().length(); 783 float distance = 0.0f; 784 float minDistance = FLT_MAX; 785 int index = 0; 786 int i = 0; 787 788 for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++) 789 { 790 if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue; 791 distance = posHuman - (*it)->getControllableEntity()->getPosition().length(); 792 if(distance < minDistance) index = i; 793 } 794 allMasters[index]->followInit(humanPawn); 795 } 796 } 801 797 802 798 /** … … 820 816 } 821 817 822 /**818 /** 823 819 @brief Master begins to follow a randomly chosen human player of the same team. Is a "specific master action". 824 820 */ … … 848 844 849 845 850 /**846 /** 851 847 @brief Master follows target with adjusted speed. Called within tick. 852 848 */ … … 860 856 861 857 862 void FormationController::setTargetPosition(const Vector3& target)858 void FormationController::setTargetPosition(const Vector3& target) 863 859 { 864 860 this->targetPosition_ = target; … … 924 920 } 925 921 926 void FormationController::forgetTarget()922 void FormationController::forgetTarget() 927 923 { 928 924 this->target_ = 0; … … 930 926 } 931 927 932 void FormationController::targetDied()928 void FormationController::targetDied() 933 929 { 934 930 this->forgetTarget(); … … 936 932 } 937 933 938 bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)934 bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 939 935 { 940 936 if (entity1 == entity2) -
code/branches/presentation2012merge/src/orxonox/gametypes/Mission.cc
r9271 r9272 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/branches/presentation2012merge/src/orxonox/infos/PlayerInfo.cc
r9257 r9272 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/branches/presentation2012merge/src/orxonox/interfaces/RadarViewable.h
r9257 r9272 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/branches/presentation2012merge/src/orxonox/worldentities/ControllableEntity.cc
r9016 r9272 87 87 this->setPriority( Priority::VeryHigh ); 88 88 this->registerVariables(); 89 89 this->team_ = -1; 90 90 } 91 91 -
code/branches/presentation2012merge/src/orxonox/worldentities/ControllableEntity.h
r9255 r9272 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/branches/presentation2012merge/src/orxonox/worldentities/pawns/Pawn.cc
r9269 r9272 232 232 { 233 233 //Applies multiplier given by the DamageBoost Pickup. 234 235 236 237 238 239 240 234 Pawn *test = dynamic_cast<Pawn *>(originator); 235 if( test != NULL ) 236 { 237 damage *= originator->getDamageMultiplier(); 238 } 239 240 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 241 241 { 242 242 if (shielddamage >= this->getShieldHealth()) -
code/branches/presentation2012merge/src/orxonox/worldentities/pawns/SpaceShip.cc
r8892 r9272 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.