Changeset 8891 for code/trunk
- Timestamp:
- Oct 12, 2011, 7:50:43 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 33 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/data/gui/scripts/QuestGUI.lua
r8858 r8891 5 5 P.questManager = nil -- The QuestManager. 6 6 P.showActive = true -- Whether the active or finished quest list is displayed. 7 P.currentQuest = nil -- The quest that is currently displayed.8 7 P.player = nil -- The player the quests are displayed for. 9 8 P.quests = {} … … 29 28 30 29 -- Load the list of quests to be displayed. 31 P.loadQuestsList(P.currentQuest) 30 P.loadQuestsList() 31 -- Pause the game - possible conflict for multiplayer quests 32 orxonox.execute("setPause 1") 33 end 34 35 function P.onQuit() 36 orxonox.execute("setPause 0") 32 37 end 33 38 … … 171 176 window:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize-P.scrollbarWidth), CEGUI.UDim(0,offset+P.borderSize))) 172 177 end 173 174 P.currentQuest = quest175 178 end 176 179 … … 204 207 end 205 208 hints:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(0, 0))) 206 207 P.currentQuest = nil208 209 end 209 210 -
code/trunk/data/levels/fightInOurBack.oxw
r8867 r8891 2 2 name = "Fight in our Back" 3 3 description = "Our fleet is far ahead of us. We need to get rid of all the enemies in its back, because we do not want our enemies to attack from everywhere. So let us clear this Sector!" 4 tags = " "4 tags = "singleplayer" 5 5 /> 6 6 -
code/trunk/data/levels/includes/weaponSettingsSwallow.oxi
r8755 r8891 14 14 </links> 15 15 <Weapon> 16 <HsW01 mode=0 munitionpershot=0 delay=0 damage=2.5 material="Flares/point_lensflare" /> 17 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=2.5 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" /> 16 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" /> 17 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" /> 18 18 19 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/> 19 20 </Weapon> 20 21 <Weapon> 21 <HsW01 mode=0 munitionpershot=0 delay=0 damage= 2.5material="Flares/point_lensflare" />22 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage= 2.5material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />22 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" /> 23 <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" /> 23 24 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/> 24 25 </Weapon> -
code/trunk/data/levels/includes/weaponSettingsTransporter.oxi
r8867 r8891 14 14 </links> 15 15 <Weapon> 16 <HsW01 mode=0 munitionpershot=0 delay=0.1 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0,0,0" />17 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />16 <HsW01 mode=0 munitionpershot=0 delay=0.1 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" /> 17 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" /> 18 18 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20 /> 19 19 </Weapon> 20 20 <Weapon> 21 <HsW01 mode=0 munitionpershot=0 delay=0.1 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0 ,0,0" />22 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="- 0.5,0.6,1.7" />21 <HsW01 mode=0 munitionpershot=0 delay=0.1 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" /> 22 <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" /> 23 23 <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20 /> 24 24 </Weapon> -
code/trunk/data/levels/lastTeamStanding.oxw
r8706 r8891 47 47 </StaticEntity> 48 48 49 <PickupSpawner position="-160,65,10" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg--> 50 <pickup> 51 <InvisiblePickup template=mediuminvisiblepickup /> 52 </pickup> 53 </PickupSpawner> 54 <PickupSpawner position="-160,60,17" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg--> 49 <PickupSpawner position="-160,60,17" triggerDistance="20" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg--> 55 50 <pickup> 56 51 <InvisiblePickup template=hugeinvisiblepickup /> -
code/trunk/data/levels/lastTeamStandingII.oxw
r8706 r8891 17 17 name = "On the fly" 18 18 description = "testmap for gametype last team standing" 19 gametype = 19 gametype = "LastTeamStanding" 20 20 > 21 21 <templates> -
code/trunk/data/levels/planets.oxw
r8706 r8891 80 80 mass="5000000" 81 81 pitch="0" 82 mesh="planets/ ganymede.mesh"82 mesh="planets/muunilinst.mesh" 83 83 atmosphere="atmosphere1" 84 84 rotationaxis="1,0,0" -
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r8858 r8891 50 50 CreateUnloadableFactory(NotificationDispatcher); 51 51 52 registerMemberNetworkFunction(NotificationDispatcher, broadcastHelper); 52 53 registerMemberNetworkFunction(NotificationDispatcher, dispatch); 53 54 … … 61 62 62 63 this->sender_ = NotificationListener::NONE; 64 this->bBroadcast_ = false; 63 65 this->registerVariables(); 64 66 } … … 81 83 SUPER(NotificationDispatcher, XMLPort, xmlelement, mode); 82 84 83 XMLPortParam(NotificationDispatcher, "sender", getSender, setSender, xmlelement, mode); 84 85 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 85 XMLPortParam(NotificationDispatcher, "sender", setSender, getSender, xmlelement, mode); 86 XMLPortParam(NotificationDispatcher, "broadcast", setBroadcasting, isBroadcasting, xmlelement, mode); 87 88 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); 86 89 } 87 90 … … 100 103 { 101 104 registerVariable(this->sender_, VariableDirection::ToClient); 105 } 106 107 /** 108 @brief 109 Broadcasts a specific Notification. 110 */ 111 void NotificationDispatcher::broadcast(void) 112 { 113 // TODO: Needed? 114 const std::string message = this->createNotificationMessage(); 115 NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::local); 116 117 // Broadcast 118 if(!GameMode::isStandalone()) 119 { 120 callMemberNetworkFunction(NotificationDispatcher, broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST); 121 } 122 } 123 124 /** 125 @brief 126 Helper function for broadcast. 127 */ 128 void NotificationDispatcher::broadcastHelper(void) 129 { 130 this->dispatch(Host::getPlayerID()); 102 131 } 103 132 … … 110 139 void NotificationDispatcher::dispatch(unsigned int clientId) 111 140 { 112 if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == 0x0) 141 // We don't call sendNotification() directly on the server, because if might be necessary that createNotificationMessage() is executed on the client as the message may be client-specific. 142 if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == ObjectDirection::None) 113 143 { 114 144 const std::string message = this->createNotificationMessage(); … … 139 169 orxout(verbose, context::notifications) << "NotificationDispatcher (&" << this << ") triggered." << endl; 140 170 171 // If the NotificationDispatcher is set to broadcast. 172 if(this->isBroadcasting()) 173 { 174 this->broadcast(); 175 return true; 176 } 177 141 178 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 142 179 PlayerInfo* player = NULL; -
code/trunk/src/modules/notifications/NotificationDispatcher.h
r7552 r8891 50 50 A NotificationDispatcher is an entity that, upon being triggered, dispatches (or sends) a specified @ref orxonox::Notification "Notification". 51 51 52 There is one parameter to be set, the @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher. 52 There are two parameter to be set: 53 - The @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher. 54 - The @b broadcast . Specifies whether messages are broadcast (i.e. sent to all clients) or just sent to a specific player. 53 55 54 56 Its standard usage is: … … 62 64 </NotificationDispatcher> 63 65 @endcode 64 But keep in mind, that NotificationDispatcher is an abstract class and in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger". 66 But keep in mind, that NotificationDispatcher is an abstract class. 67 Also in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger". 68 If the NotificationDispatcher is not set to broadcast only events caused by @ref orxonox::PlayerTrigger "PlayerTriggers" trigger a message since the information obtained by the @ref orxonox::PlayerTrigger "PlayerTrigger" is used to identify the client to which the message should be sent. 65 69 66 70 @author … … 84 88 const std::string& getSender(void) const 85 89 { return this->sender_; } 86 90 /** 87 91 @brief Set the sender of the Notification dispatched by this NotificationDispatcher. 88 92 @param sender The name of the sender. … … 91 95 { this->sender_ = sender; } 92 96 93 void dispatch(unsigned int clientId); //!< Dispatches a specific Notification. 97 /** 98 @brief Check whether the NotificationDispatcher is set to broadcast. 99 @return Returns true if the NotificationDispatcher is set to broadcast. 100 */ 101 bool isBroadcasting(void) const 102 { return this->bBroadcast_; } 103 /** 104 @brief Set the NotificationDispatcher to broadcast. 105 @param broadcast Whether the NotificationDispatcher is set to broadcast or singlecast. 106 */ 107 void setBroadcasting(bool v) 108 { this->bBroadcast_ = v; } 109 110 void broadcast(void); //!< Broadcasts a specific Notification. 111 void broadcastHelper(void); //!< Helper function for broadcast. 112 void dispatch(unsigned int clientId); //!< Dispatches a specific Notification to a given client. 94 113 bool trigger(bool triggered, BaseObject* trigger); //!< Is called when the NotificationDispatcher is triggered. 95 114 96 115 protected: 97 116 std::string sender_; //!< The name of the sender of the Notification dispatched by this NotificationDispatcher. 117 bool bBroadcast_; //!< Whether the NotificationDispatcher is broadcasting. 98 118 99 119 void registerVariables(void); //!< Register some variables for synchronisation. … … 105 125 */ 106 126 virtual const std::string& createNotificationMessage(void) 107 { return *(new std::string("")); }127 { return BLANKSTRING; } 108 128 109 129 }; -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r8858 r8891 63 63 { 64 64 SetConfigValue(markerLimit_, 3); 65 65 66 } 66 67 … … 77 78 setTextSize ( 0.05f ); 78 79 setNavMarkerSize ( 0.05f ); 80 setDetectionLimit( 10000.0f ); 79 81 } 80 82 … … 95 97 SUPER ( HUDNavigation, XMLPort, xmlelement, mode ); 96 98 97 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 98 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 99 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 99 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 100 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 101 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 102 XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 100 103 } 101 104 … … 161 164 162 165 unsigned int markerCount_ = 0; 163 166 bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player 164 167 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 165 168 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt ) 166 169 { 167 170 ObjectMap::iterator it = activeObjectList_.find ( listIt->first ); 168 169 if ( markerCount_ < markerLimit_ )171 closeEnough_ = listIt->second < detectionLimit_ ; 172 if ( markerCount_ < markerLimit_ && (closeEnough_ || detectionLimit_ < 0) ) // display on HUD if the statement is true 170 173 { 171 174 … … 277 280 it->second.text_->show(); 278 281 } 279 else 282 else // do not display on HUD 280 283 { 281 284 it->second.panel_->hide(); … … 309 312 void HUDNavigation::addObject ( RadarViewable* object ) 310 313 { 311 if( showObject(object) ==false )314 if( showObject(object) == false ) 312 315 return; 313 316 … … 396 399 return false; 397 400 assert( rv->getWorldEntity() ); 398 if ( rv->getWorldEntity()->isVisible() ==false || rv->getRadarVisibility()==false )401 if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false ) 399 402 return false; 400 403 return true; -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r7401 r8891 85 85 { return navMarkerSize_; } 86 86 87 void setDetectionLimit( float limit ) 88 { this->detectionLimit_ = limit; } 89 float getDetectionLimit() const 90 { return this->detectionLimit_; } 91 87 92 void setTextSize ( float size ); 88 93 float getTextSize() const; … … 102 107 float textSize_; 103 108 104 unsigned int markerLimit_; ;//TODO: is it possible to set this over the console and/or the IG-Setting105 106 109 unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting 110 float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 111 //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite". 107 112 }; 108 113 } -
code/trunk/src/modules/overlays/hud/HUDRadar.cc
r8858 r8891 64 64 this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png"; 65 65 this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.png"; 66 66 this->setDetectionLimit( 10000.0f ); 67 67 this->owner_ = 0; 68 68 } … … 93 93 { 94 94 if (object == dynamic_cast<RadarViewable*>(this->owner_)) 95 return; 96 if( showObject(object) == false ) //do not show objects that are "invisible" or "radar invisible" 95 97 return; 96 98 … … 123 125 124 126 void HUDRadar::objectChanged( RadarViewable* rv ) 125 { 126 if (rv == dynamic_cast<RadarViewable*>(this->owner_)) 127 return; 128 assert( this->radarObjects_.find(rv) != this->radarObjects_.end() ); 129 Ogre::PanelOverlayElement* panel = this->radarObjects_[rv]; 130 panel->setMaterialName(TextureGenerator::getMaterialName( 131 shapeMaterials_[rv->getRadarObjectShape()], rv->getRadarObjectColour())); 127 {// The new implementation behaves more precisely, since inactive RadarViewables are not displayed anymore. 128 this->removeObject(rv); 129 this->addObject(rv); 132 130 } 133 131 … … 174 172 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture 175 173 it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 176 it->second->show(); 174 if( distance < detectionLimit_ || detectionLimit_ < 0 ) 175 it->second->show(); 176 else 177 it->second->hide(); 177 178 178 179 // if this object is in focus, then set the focus marker … … 186 187 } 187 188 189 bool HUDRadar::showObject(RadarViewable* rv) 190 { 191 if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) ) 192 return false; 193 assert( rv->getWorldEntity() ); 194 if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false ) 195 return false; 196 return true; 197 } 198 199 188 200 void HUDRadar::changedOwner() 189 201 { -
code/trunk/src/modules/overlays/hud/HUDRadar.h
r7880 r8891 57 57 void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; } 58 58 59 void setDetectionLimit( float limit ) 60 { this->detectionLimit_ = limit; } 61 float getDetectionLimit() const 62 { return this->detectionLimit_; } 63 59 64 float getMaximumDotSize() const { return this->maximumDotSize_; } 60 65 void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } … … 69 74 virtual void objectChanged( RadarViewable* rv ); 70 75 void radarTick(float dt); 76 bool showObject( RadarViewable* rv ); //!< Do not display an object on radar, if showObject(.) is false. 71 77 72 78 void gatherObjects(); … … 83 89 84 90 float sensitivity_; 85 91 float detectionLimit_; 86 92 ControllableEntity* owner_; 87 93 }; -
code/trunk/src/modules/pickup/PickupSpawner.cc
r8858 r8891 181 181 if(GameMode::isMaster() && this->isActive()) 182 182 { 183 SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)183 WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 184 184 185 185 // Remove PickupCarriers from the blocked list if they have exceeded their time. … … 195 195 for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 196 196 { 197 if(spawner == NULL) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute). 198 break; 199 197 200 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 198 201 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it); 199 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawn der, is in trigger-distance and the carrier is not blocked.202 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawner, is in trigger-distance and the carrier is not blocked. 200 203 if(distance.length() < this->triggerDistance_ && carrier != NULL && this->blocked_.find(carrier) == this->blocked_.end()) 201 204 { -
code/trunk/src/modules/questsystem/QuestItem.h
r7552 r8891 105 105 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 106 106 107 bool registered_; 107 bool registered_; //!< Whether the QuestItem is registered with the QuestManager. 108 108 109 109 }; -
code/trunk/src/modules/questsystem/QuestManager.cc
r8858 r8891 35 35 36 36 #include "util/Exception.h" 37 #include "util/OrxAssert.h" 37 38 #include "util/ScopedSingletonManager.h" 38 39 #include "core/command/ConsoleCommand.h" … … 60 61 { 61 62 RegisterRootObject(QuestManager); 62 63 63 orxout(internal_info, context::quests) << "QuestManager created." << endl; 64 64 } … … 95 95 bool QuestManager::registerQuest(Quest* quest) 96 96 { 97 assert(quest); 97 if(quest == NULL) 98 { 99 COUT(1) << "Quest pointer is NULL." << endl; 100 return false; 101 } 98 102 99 103 std::pair<std::map<std::string, Quest*>::iterator,bool> result; … … 133 137 bool QuestManager::registerHint(QuestHint* hint) 134 138 { 135 assert(hint); 139 if(hint == NULL) 140 { 141 COUT(1) << "Hint pointer is NULL." << endl; 142 return false; 143 } 136 144 137 145 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; … … 361 369 Quest* QuestManager::getParentQuest(Quest* quest) 362 370 { 371 OrxAssert(quest, "The input Quest is NULL."); 363 372 return quest->getParentQuest(); 364 373 } … … 374 383 QuestDescription* QuestManager::getDescription(Quest* item) 375 384 { 385 OrxAssert(item, "The input Quest is NULL."); 376 386 return item->getDescription(); 377 387 } … … 387 397 QuestDescription* QuestManager::getDescription(QuestHint* item) 388 398 { 399 OrxAssert(item, "The input QuestHint is NULL."); 389 400 return item->getDescription(); 390 401 } … … 400 411 const std::string QuestManager::getId(Quest* item) const 401 412 { 413 OrxAssert(item, "The input Quest is NULL."); 402 414 return item->getId(); 403 415 } … … 413 425 const std::string QuestManager::getId(QuestHint* item) const 414 426 { 427 OrxAssert(item, "The input QuestHint is NULL."); 415 428 return item->getId(); 416 429 } -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r8855 r8891 66 66 this->localAngularVelocity_ = 0; 67 67 this->lifetime_ = 100.0f; 68 this->bIsRocket_= true; 68 69 69 70 if (GameMode::isMaster()) … … 134 135 if(this->isInitialized()) 135 136 { 137 this->bIsRocket_= false; 136 138 if (GameMode::isMaster()) 137 139 { -
code/trunk/src/orxonox/LevelManager.cc
r8858 r8891 87 87 void LevelManager::setConfigValues() 88 88 { 89 SetConfigValue(defaultLevelName_, " presentationDM.oxw")89 SetConfigValue(defaultLevelName_, "missionOne.oxw") 90 90 .description("Sets the pre selection of the level in the main menu."); 91 91 } … … 158 158 if (this->levels_.size() > 0) 159 159 { 160 // Activate the level that is the first in the list of levels whose activity has been requested. 160 // Activate the level that is the first in the list of levels whose activity has been requested. 161 161 this->levels_.front()->setActive(true); 162 162 // Make every player enter the newly activated level. … … 272 272 Loader::unload(&file); 273 273 274 if(info == NULL) 274 if(info == NULL) 275 275 { 276 276 // Create a default LevelInfoItem object that merely contains the name -
code/trunk/src/orxonox/controllers/AIController.cc
r8729 r8891 65 65 if (this->freedomCount_ == 1) 66 66 { 67 this->state_ = SLAVE;68 this->freedomCount_ = 0;67 this->state_ = SLAVE; 68 this->freedomCount_ = 0; 69 69 } 70 70 … … 76 76 // search enemy 77 77 random = rnd(maxrand); 78 if (random < 15&& (!this->target_))78 if (random < (15 + botlevel_* 20) && (!this->target_)) 79 79 this->searchNewTarget(); 80 80 81 81 // forget enemy 82 82 random = rnd(maxrand); 83 if (random < 5&& (this->target_))83 if (random < ((1-botlevel_)*6) && (this->target_)) 84 84 this->forgetTarget(); 85 85 86 86 // next enemy 87 87 random = rnd(maxrand); 88 if (random < 10&& (this->target_))88 if (random < (botlevel_*20) && (this->target_)) 89 89 this->searchNewTarget(); 90 90 … … 106 106 // shoot 107 107 random = rnd(maxrand); 108 if (!(this->passive_) && random < 75&& (this->target_ && !this->bShooting_))108 if (!(this->passive_) && random < (75 + botlevel_*25) && (this->target_ && !this->bShooting_)) 109 109 this->bShooting_ = true; 110 110 111 111 // stop shooting 112 112 random = rnd(maxrand); 113 if (random < 25&& (this->bShooting_))113 if (random < ((1 - botlevel_)*25) && (this->bShooting_)) 114 114 this->bShooting_ = false; 115 116 // boost 117 random = rnd(maxrand); 118 if (random < botlevel_*100 ) 119 this->boostControl(); 120 121 // update Checkpoints 122 /*random = rnd(maxrand); 123 if (this->defaultWaypoint_ && random > (maxrand-10)) 124 this->manageWaypoints(); 125 else //if(random > maxrand-10) //CHECK USABILITY!!*/ 126 if (this->waypoints_.size() == 0 ) 127 this->manageWaypoints(); 115 128 116 129 } … … 159 172 // search enemy 160 173 random = rnd(maxrand); 161 if (random < 15 && (!this->target_))174 if (random < (botlevel_)*25 && (!this->target_)) 162 175 this->searchNewTarget(); 163 176 164 177 // forget enemy 165 178 random = rnd(maxrand); 166 if (random < 5&& (this->target_))179 if (random < (1-botlevel_)*6 && (this->target_)) 167 180 this->forgetTarget(); 168 181 … … 185 198 // shoot 186 199 random = rnd(maxrand); 187 if (!(this->passive_) && random < 9&& (this->target_ && !this->bShooting_))188 { 189 this->bShooting_ = true;190 this->forceFreeSlaves();200 if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_)) 201 { 202 this->bShooting_ = true; 203 this->forceFreeSlaves(); 191 204 } 192 205 193 206 // stop shooting 194 207 random = rnd(maxrand); 195 if (random < 25&& (this->bShooting_))208 if (random < ( (1- botlevel_)*25 ) && (this->bShooting_)) 196 209 this->bShooting_ = false; 197 210 211 // boost 212 random = rnd(maxrand); 213 if (random < botlevel_*100 ) 214 this->boostControl(); 215 216 // update Checkpoints 217 /*random = rnd(maxrand); 218 if (this->defaultWaypoint_ && random > (maxrand-10)) 219 this->manageWaypoints(); 220 else //if(random > maxrand-10) //CHECK USABILITY!!*/ 221 if (this->waypoints_.size() == 0 ) 222 this->manageWaypoints(); 198 223 } 199 224 } … … 206 231 return; 207 232 208 if (this->state_ == MASTER) 233 float random; 234 float maxrand = 100.0f / ACTION_INTERVAL; 235 ControllableEntity* controllable = this->getControllableEntity(); 236 237 if (controllable && this->mode_ == DEFAULT)// bot is ready to move to a target 209 238 { 210 if (this->specificMasterAction_ == NONE) 239 if (this->waypoints_.size() > 0 ) //Waypoint functionality. 240 { 241 WorldEntity* wPoint = this->waypoints_[this->waypoints_.size()-1]; 242 if(wPoint) 243 { 244 this->moveToPosition(wPoint->getWorldPosition()); //BUG ?? sometime wPoint->getWorldPosition() causes crash 245 if (wPoint->getWorldPosition().squaredDistance(controllable->getPosition()) <= this->squaredaccuracy_) 246 this->waypoints_.pop_back(); // if goal is reached, remove it from the list 247 } 248 else 249 this->waypoints_.pop_back(); // remove invalid waypoints 250 251 } 252 else if(this->defaultWaypoint_ && ((this->defaultWaypoint_->getPosition()-controllable->getPosition()).length() > 200.0f)) 253 { 254 this->moveToPosition(this->defaultWaypoint_->getPosition()); // stay within a certain range of the defaultWaypoint_ 255 random = rnd(maxrand); 256 } 257 } 258 if(this->mode_ == DEFAULT) 259 { 260 if (this->state_ == MASTER) 261 { 262 if (this->specificMasterAction_ == NONE) 263 { 264 if (this->target_) 265 { 266 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 267 this->forgetTarget(); 268 else 269 { 270 this->aimAtTarget(); 271 random = rnd(maxrand); 272 if(this->botlevel_*100 > random && !this->isCloseAtTarget(20)) 273 this->follow(); //If a bot is shooting a player, it shouldn't let him go away easily. 274 } 275 } 276 277 if (this->bHasTargetPosition_) 278 this->moveToTargetPosition(); 279 280 this->doFire(); 281 } 282 283 if (this->specificMasterAction_ == TURN180) 284 this->turn180(); 285 286 if (this->specificMasterAction_ == SPIN) 287 this->spin(); 288 if (this->specificMasterAction_ == FOLLOW) 289 this->follow(); 290 } 291 292 if (this->state_ == SLAVE) 293 { 294 if (this->bHasTargetPosition_) 295 this->moveToTargetPosition(); 296 } 297 298 if (this->state_ == FREE) 211 299 { 212 300 if (this->target_) … … 214 302 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 215 303 this->forgetTarget(); 216 else this->aimAtTarget(); 304 else 305 { 306 this->aimAtTarget(); 307 random = rnd(maxrand); 308 309 if(this->botlevel_*100 > random && !this->isCloseAtTarget(20)) 310 this->follow();//If a bot is shooting a player, it shouldn't let him go away easily. 311 } 217 312 } 218 313 … … 220 315 this->moveToTargetPosition(); 221 316 222 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 223 this->getControllableEntity()->fire(0); 224 } 225 226 if (this->specificMasterAction_ == TURN180) 227 this->turn180(); 228 229 if (this->specificMasterAction_ == SPIN) 230 this->spin(); 231 if (this->specificMasterAction_ == FOLLOW) 317 this->doFire(); 318 } 319 }//END_OF DEFAULT MODE 320 else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant. 321 { //Vector-implementation: mode_.back() == ROCKET; 322 if(controllable) 323 { 324 if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over. 325 { 232 326 this->follow(); 233 } 234 235 if (this->state_ == SLAVE) 236 { 237 238 if (this->bHasTargetPosition_) 239 this->moveToTargetPosition(); 240 241 } 242 243 if (this->state_ == FREE) 244 { 245 if (this->target_) 246 { 247 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 248 this->forgetTarget(); 249 else this->aimAtTarget(); 250 } 251 252 if (this->bHasTargetPosition_) 253 this->moveToTargetPosition(); 254 255 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 256 this->getControllableEntity()->fire(0); 257 } 327 this->timeout_ -= dt; 328 if((timeout_< 0)||(!target_))//Check if the timeout is over or target died. 329 { 330 controllable->fire(0);//kill the rocket 331 this->setPreviousMode();//get out of rocket mode 332 } 333 } 334 else 335 this->setPreviousMode();//no rocket entity -> get out of rocket mode 336 } 337 else 338 this->setPreviousMode();//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode 339 }//END_OF ROCKET MODE 258 340 259 341 SUPER(AIController, tick, dt); -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r8858 r8891 39 39 #include "worldentities/pawns/Pawn.h" 40 40 #include "worldentities/pawns/TeamBaseMatchBase.h" 41 #include "worldentities/pawns/SpaceShip.h" 41 42 #include "gametypes/TeamDeathmatch.h" 42 43 #include "gametypes/Dynamicmatch.h" … … 44 45 #include "controllers/NewHumanController.h" 45 46 #include "controllers/DroneController.h" 47 #include "weaponsystem/WeaponMode.h" 48 #include "weaponsystem/WeaponPack.h" 49 #include "weaponsystem/Weapon.h" 50 #include "weaponsystem/WeaponSlot.h" 51 #include "weaponsystem/WeaponSlot.h" 46 52 47 53 namespace orxonox … … 52 58 SetConsoleCommand("ArtificialController", "passivebehaviour", &ArtificialController::passivebehaviour); 53 59 SetConsoleCommand("ArtificialController", "formationsize", &ArtificialController::formationsize); 60 SetConsoleCommand("ArtificialController", "setbotlevel", &ArtificialController::setAllBotLevel); 54 61 55 62 static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7; … … 84 91 85 92 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 93 this->bSetupWorked = false; 94 this->botlevel_ = 0.5f; 95 this->mode_ = DEFAULT;////Vector-implementation: mode_.push_back(DEFAULT); 96 this->timeout_ = 0; 97 this->currentWaypoint_ = 0; 98 this->setAccuracy(5); 99 this->defaultWaypoint_ = NULL; 86 100 } 87 101 … … 89 103 { 90 104 if (this->isInitialized()) 91 { 105 {//Vector-implementation: mode_.erase(mode_.begin(),mode_.end()); 106 this->waypoints_.clear(); 92 107 this->removeFromFormation(); 93 108 this->weaponModes_.clear(); 94 109 for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it; ++it) 95 110 { … … 305 320 if (!this->getControllableEntity()) 306 321 this->removeFromFormation(); 322 this->bSetupWorked = false; // reset weapon information 323 this->setupWeapons(); 307 324 } 308 325 … … 387 404 } 388 405 } 406 407 void ArtificialController::absoluteMoveToPosition(const Vector3& target) 408 { 409 float minDistance = 40.0f; 410 if (!this->getControllableEntity()) 411 return; 412 413 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 414 float distance = (target - this->getControllableEntity()->getPosition()).length(); 415 416 if (this->target_ || distance > minDistance) 417 { 418 // Multiply with ROTATEFACTOR_FREE to make them a bit slower 419 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * sgn(coord.x) * coord.x*coord.x); 420 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * sgn(coord.y) * coord.y*coord.y); 421 this->getControllableEntity()->moveFrontBack(SPEED_FREE); 422 } 423 424 425 if (distance < minDistance) 426 { 427 this->positionReached(); 428 } 429 } 430 389 431 390 432 void ArtificialController::moveToTargetPosition() … … 915 957 bool ArtificialController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 916 958 { 959 if(!entity1 || !entity2) 960 return true; 917 961 if (entity1 == entity2) 918 962 return true; … … 1020 1064 return (team1 == team2 && team1 != -1); 1021 1065 } 1066 1067 /** 1068 @brief DoFire is called when a bot should shoot and decides which weapon is used and whether the bot shoots at all. 1069 */ 1070 void ArtificialController::doFire() 1071 { 1072 if(!this->bSetupWorked)//setup: find out which weapons are active ! hard coded: laser is "0", lens flare is "1", ... 1073 { 1074 this->setupWeapons(); 1075 } 1076 else if(this->getControllableEntity() && weaponModes_.size()&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f)) 1077 { 1078 int firemode; 1079 float random = rnd(1);// 1080 if (this->isCloseAtTarget(130) && (firemode = getFiremode("LightningGun")) > -1 ) 1081 {//LENSFLARE: short range weapon 1082 this->getControllableEntity()->fire(firemode); //ai uses lens flare if they're close enough to the target 1083 } 1084 else if( this->isCloseAtTarget(400) && (random < this->botlevel_) && (firemode = getFiremode("RocketFire")) > -1 ) 1085 {//ROCKET: mid range weapon 1086 this->mode_ = ROCKET; //Vector-implementation: mode_.push_back(ROCKET); 1087 this->getControllableEntity()->fire(firemode); //launch rocket 1088 if(this->getControllableEntity() && this->target_) //after fire(3) is called, getControllableEntity() refers to the rocket! 1089 { 1090 float speed = this->getControllableEntity()->getVelocity().length() - target_->getVelocity().length(); 1091 if(!speed) speed = 0.1f; 1092 float distance = target_->getPosition().length() - this->getControllableEntity()->getPosition().length(); 1093 this->timeout_= distance/speed*sgn(speed*distance) + 1.8f; //predicted time of target hit (+ tolerance) 1094 } 1095 else 1096 this->timeout_ = 4.0f; //TODO: find better default value 1097 } 1098 else if ((firemode = getFiremode("HsW01")) > -1 ) //LASER: default weapon 1099 this->getControllableEntity()->fire(firemode); 1100 } 1101 } 1102 1103 /** 1104 @brief Information gathering: Which weapons are ready to use? 1105 */ 1106 void ArtificialController::setupWeapons() //TODO: Make this function generic!! (at the moment is is based on conventions) 1107 { 1108 this->bSetupWorked = false; 1109 if(this->getControllableEntity()) 1110 { 1111 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity()); 1112 if(pawn) 1113 { 1114 this->weaponModes_.clear(); // reset previous weapon information 1115 WeaponSlot* wSlot = 0; 1116 for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++) 1117 { 1118 WeaponMode* wMode = 0; 1119 for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++) 1120 { 1121 std::string wName = wMode->getIdentifier()->getName(); 1122 if(this->getFiremode(wName) == -1) //only add a weapon, if it is "new" 1123 weaponModes_[wName] = wMode->getMode(); 1124 } 1125 } 1126 if(weaponModes_.size())//at least one weapon detected 1127 this->bSetupWorked = true; 1128 }//pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user); 1129 } 1130 } 1131 1132 1133 void ArtificialController::setBotLevel(float level) 1134 { 1135 if (level < 0.0f) 1136 this->botlevel_ = 0.0f; 1137 else if (level > 1.0f) 1138 this->botlevel_ = 1.0f; 1139 else 1140 this->botlevel_ = level; 1141 } 1142 1143 void ArtificialController::setAllBotLevel(float level) 1144 { 1145 for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it) 1146 it->setBotLevel(level); 1147 } 1148 1149 void ArtificialController::setPreviousMode() 1150 { 1151 this->mode_ = DEFAULT; //Vector-implementation: mode_.pop_back(); 1152 } 1153 1154 /** 1155 @brief Manages boost. Switches between boost usage and boost safe mode. 1156 */ 1157 void ArtificialController::boostControl() 1158 { 1159 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 1160 if(ship == NULL) return; 1161 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost 1162 this->getControllableEntity()->boost(true); 1163 else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower()) //lower limit ->do not boost 1164 this->getControllableEntity()->boost(false); 1165 } 1166 1167 int ArtificialController::getFiremode(std::string name) 1168 { 1169 for (std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it) 1170 { 1171 if (it->first == name) 1172 return it->second; 1173 } 1174 return -1; 1175 } 1176 1177 void ArtificialController::addWaypoint(WorldEntity* waypoint) 1178 { 1179 this->waypoints_.push_back(waypoint); 1180 } 1181 1182 WorldEntity* ArtificialController::getWaypoint(unsigned int index) const 1183 { 1184 if (index < this->waypoints_.size()) 1185 return this->waypoints_[index]; 1186 else 1187 return 0; 1188 } 1189 1190 /** 1191 @brief Adds first waypoint of type name to the waypoint stack, which is within the searchDistance 1192 @param name object-name of a point of interest (e.g. "PickupSpawner", "ForceField") 1193 */ 1194 void ArtificialController::updatePointsOfInterest(std::string name, float searchDistance) 1195 { 1196 WorldEntity* waypoint = NULL; 1197 for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it) 1198 { 1199 if((*it)->getIdentifier() == ClassByString(name)) 1200 { 1201 ControllableEntity* controllable = this->getControllableEntity(); 1202 if(!controllable) continue; 1203 float actualDistance = ( (*it)->getPosition() - controllable->getPosition() ).length(); 1204 if(actualDistance > searchDistance || actualDistance < 5.0f) continue; 1205 // TODO: PickupSpawner: adjust waypoint accuracy to PickupSpawner's triggerdistance 1206 // TODO: ForceField: analyze is angle between forcefield boost and own flying direction is acceptable 1207 else 1208 { 1209 waypoint = *it; 1210 break; 1211 } 1212 } 1213 } 1214 if(waypoint) 1215 this->waypoints_.push_back(waypoint); 1216 } 1217 1218 /** 1219 @brief Adds point of interest depending on context. Further Possibilites: "ForceField", "PortalEndPoint", "MovableEntity", "Dock" 1220 */ 1221 void ArtificialController::manageWaypoints() 1222 { 1223 if(!defaultWaypoint_) 1224 this->updatePointsOfInterest("PickupSpawner", 200.0f); // long search radius if there is no default goal 1225 else 1226 this->updatePointsOfInterest("PickupSpawner", 20.0f); // take pickup en passant if there is a default waypoint 1227 } 1228 1022 1229 } -
code/trunk/src/orxonox/controllers/ArtificialController.h
r8706 r8891 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include < vector>34 #include <map> 35 35 36 36 #include "util/Math.h" 37 37 #include "Controller.h" 38 38 #include "controllers/NewHumanController.h" 39 #include "weaponsystem/WeaponSystem.h" 39 40 40 41 namespace orxonox … … 78 79 static void formationsize(const int size); 79 80 81 virtual void doFire(); 82 void setBotLevel(float level=1.0f); 83 inline float getBotLevel() const 84 { return this->botlevel_; } 85 static void setAllBotLevel(float level); 86 //WAYPOINT FUNCTIONS 87 void addWaypoint(WorldEntity* waypoint); 88 WorldEntity* getWaypoint(unsigned int index) const; 89 90 inline void setAccuracy(float accuracy) 91 { this->squaredaccuracy_ = accuracy*accuracy; } 92 inline float getAccuracy() const 93 { return sqrt(this->squaredaccuracy_); } 94 void updatePointsOfInterest(std::string name, float distance); 95 void manageWaypoints(); 96 80 97 protected: 81 98 … … 96 113 void moveToPosition(const Vector3& target); 97 114 void moveToTargetPosition(); 115 void absoluteMoveToPosition(const Vector3& target); 98 116 99 117 virtual void positionReached() {} … … 135 153 136 154 static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack 155 void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost. 137 156 138 157 bool bHasTargetPosition_; … … 141 160 bool bShooting_; 142 161 143 private: 162 float botlevel_; //<! Makes the level of a bot configurable. 163 enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes 164 Mode mode_; //TODO: replace single value with stack-like implementation: std::vector<Mode> mode_; 165 void setPreviousMode(); 166 167 //WEAPONSYSTEM DATA 168 std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode- managed by setupWeapons() 169 //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons() 170 float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.) 171 void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed. 172 bool bSetupWorked; //<! If false, setupWeapons() is called. 173 int getFiremode(std::string name); 174 175 //WAYPOINT DATA 176 std::vector<WeakPtr<WorldEntity> > waypoints_; 177 size_t currentWaypoint_; 178 float squaredaccuracy_; 179 WorldEntity* defaultWaypoint_; 144 180 }; 145 181 } -
code/trunk/src/orxonox/controllers/DroneController.cc
r8729 r8891 52 52 this->drone_ = 0; 53 53 this->isShooting_ = false; 54 this->setAccuracy(10); 54 55 55 56 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this))); … … 92 93 The duration of the tick. 93 94 */ 95 /* PORTALS workaround: 96 if the owner uses a portal -> distance between owner and drone is huge -> is detected by drone 97 -> drone searches for portal -> drone adds portal as waypoint -> drone flies towards portal //ignores owner 98 -> if the drone used a portal, then the distance to the owner is small -> remove waypoint // back to normal mode 99 100 */ 94 101 void DroneController::tick(float dt) 95 102 { 96 103 if (this->getDrone() && this->getOwner()) 97 104 { 98 if (this->target_) 105 if (this->waypoints_.size() > 0 ) //Waypoint functionality: Drone should follow it's master through portals 106 {// Idea: after using the the portal, the master is far away. 107 WorldEntity* wPoint = this->waypoints_[this->waypoints_.size()-1]; 108 if(wPoint) 109 { 110 float distanceToOwnerSquared = (this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength(); 111 this->absoluteMoveToPosition(wPoint->getWorldPosition()); //simplified function - needs WORKAROUND 112 if (distanceToOwnerSquared <= 90000.0f) //WORKAROUND: if the Drone is again near its owner, the portal has been used correctly. 113 { 114 this->waypoints_.pop_back(); // if goal is reached, remove it from the list 115 this->positionReached(); //needed?? 116 } 117 118 } 119 else 120 this->waypoints_.pop_back(); // remove invalid waypoints 121 } 122 else 99 123 { 100 float distanceToTargetSquared = (this->getDrone()->getWorldPosition() - this->target_->getWorldPosition()).squaredLength(); 101 if (distanceToTargetSquared < (this->getDrone()->getMaxShootingRange()*this->getDrone()->getMaxShootingRange())) 124 if (this->target_) 102 125 { 103 this->isShooting_ = true; 104 this->aimAtTarget(); 105 this->getDrone()->fire(0); 126 float distanceToTargetSquared = (this->getDrone()->getWorldPosition() - this->target_->getWorldPosition()).squaredLength(); 127 if (distanceToTargetSquared < (this->getDrone()->getMaxShootingRange()*this->getDrone()->getMaxShootingRange())) 128 { 129 this->isShooting_ = true; 130 this->aimAtTarget(); 131 if(!this->friendlyFire()) 132 this->getDrone()->fire(0); 133 } 134 } 135 136 137 float maxDistanceSquared = this->getDrone()->getMaxDistanceToOwner()*this->getDrone()->getMaxDistanceToOwner(); 138 float minDistanceSquared = this->getDrone()->getMinDistanceToOwner()*this->getDrone()->getMinDistanceToOwner(); 139 if((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() > 20.0f*maxDistanceSquared) 140 {//FIX: if the drone's owner uses portal, the drone searches for the portal & adds it as a waypoint. 141 this->updatePointsOfInterest("PortalEndPoint", 500.0f); //possible conflict: speed-pickup 106 142 } 143 if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() > maxDistanceSquared) 144 { 145 this->moveToPosition(this->getOwner()->getWorldPosition()); //fly towards owner 146 } 147 else if((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() < minDistanceSquared) 148 { 149 this->moveToPosition(-this->getOwner()->getWorldPosition()); //fly away from owner 150 } 151 else if (!this->isShooting_) 152 { 153 float random = rnd(2.0f); 154 float randomSelection = rnd(6.0f); 155 if((int)randomSelection==0) drone_->moveUpDown(random); 156 else if((int)randomSelection==1) drone_->moveRightLeft(random); 157 else if((int)randomSelection==2) drone_->moveFrontBack(random); 158 else if((int)randomSelection==3) drone_->rotateYaw(random); 159 else if((int)randomSelection==4) drone_->rotatePitch(random); 160 else if((int)randomSelection==5) drone_->rotateRoll(random); 161 } 162 163 this->isShooting_ = false; 107 164 } 108 109 float maxDistanceSquared = this->getDrone()->getMaxDistanceToOwner()*this->getDrone()->getMaxDistanceToOwner();110 float minDistanceSquared = this->getDrone()->getMinDistanceToOwner()*this->getDrone()->getMinDistanceToOwner();111 if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() > maxDistanceSquared)112 {113 this->moveToPosition(this->getOwner()->getWorldPosition()); //fly towards owner114 }115 else if((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() < minDistanceSquared)116 {117 this->moveToPosition(-this->getOwner()->getWorldPosition()); //fly away from owner118 }119 else if (!this->isShooting_)120 {121 float random = rnd(2.0f);122 float randomSelection = rnd(6.0f);123 if((int)randomSelection==0) drone_->moveUpDown(random);124 else if((int)randomSelection==1) drone_->moveRightLeft(random);125 else if((int)randomSelection==2) drone_->moveFrontBack(random);126 else if((int)randomSelection==3) drone_->rotateYaw(random);127 else if((int)randomSelection==4) drone_->rotatePitch(random);128 else if((int)randomSelection==5) drone_->rotateRoll(random);129 }130 131 this->isShooting_ = false;132 165 } 133 134 166 SUPER(AIController, tick, dt); 135 136 167 } 137 168 … … 147 178 this->destroy(); 148 179 } 180 181 bool DroneController::friendlyFire() 182 { ControllableEntity* droneEntity_ = this->getControllableEntity(); 183 if (!droneEntity_) return false; 184 if(!owner_) return false; 185 if(this->bHasTargetPosition_) 186 { 187 Vector3 ownerPosition_ = owner_->getPosition(); 188 Vector3 toOwner_ = owner_->getPosition() - droneEntity_->getPosition(); 189 Vector3 toTarget_ = targetPosition_ - droneEntity_->getPosition(); 190 if(toTarget_.length() < toOwner_.length()) return false; //owner is far away = in safty 191 float angleToOwner = getAngle(droneEntity_->getPosition(), droneEntity_->getOrientation() * WorldEntity::FRONT, ownerPosition_); 192 float angleToTarget = getAngle(droneEntity_->getPosition(), droneEntity_->getOrientation() * WorldEntity::FRONT, targetPosition_); 193 float angle = angleToOwner - angleToTarget;//angle between target and owner, observed by the drone 194 if(std::sin(angle)*toOwner_.length() < 5.0f)//calculate owner's distance to shooting line 195 return true; 196 } 197 return false;//Default return value: Usually there is no friendlyFire 198 } 149 199 } -
code/trunk/src/orxonox/controllers/DroneController.h
r8729 r8891 66 66 virtual void action(); 67 67 void ownerDied(); 68 bool friendlyFire(); //<! returns true if the owner_ would be hit. 68 69 bool isShooting_; 69 70 -
code/trunk/src/orxonox/controllers/WaypointController.cc
r5929 r8891 40 40 { 41 41 RegisterObject(WaypointController); 42 43 this->currentWaypoint_ = 0;44 42 this->setAccuracy(100); 45 43 } … … 47 45 WaypointController::~WaypointController() 48 46 { 49 if (this->isInitialized())47 for (size_t i = 0; i < this->waypoints_.size(); ++i) 50 48 { 51 for (size_t i = 0; i < this->waypoints_.size(); ++i)49 if(this->waypoints_[i]) 52 50 this->waypoints_[i]->destroy(); 53 51 } … … 58 56 SUPER(WaypointController, XMLPort, xmlelement, mode); 59 57 60 XMLPortParam( WaypointController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f);61 XMLPortObject( WaypointController, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode);58 XMLPortParam(ArtificialController, "accuracy", setAccuracy, getAccuracy, xmlelement, mode).defaultValues(100.0f); 59 XMLPortObject(ArtificialController, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode); 62 60 } 63 61 … … 76 74 } 77 75 78 void WaypointController::addWaypoint(WorldEntity* waypoint)79 {80 this->waypoints_.push_back(waypoint);81 }82 83 WorldEntity* WaypointController::getWaypoint(unsigned int index) const84 {85 if (index < this->waypoints_.size())86 return this->waypoints_[index];87 else88 return 0;89 }90 76 } -
code/trunk/src/orxonox/controllers/WaypointController.h
r5781 r8891 47 47 virtual void tick(float dt); 48 48 49 void addWaypoint(WorldEntity* waypoint); 50 WorldEntity* getWaypoint(unsigned int index) const; 49 protected: 51 50 52 inline void setAccuracy(float accuracy)53 { this->squaredaccuracy_ = accuracy*accuracy; }54 inline float getAccuracy() const55 { return sqrt(this->squaredaccuracy_); }56 57 protected:58 std::vector<WorldEntity*> waypoints_;59 size_t currentWaypoint_;60 float squaredaccuracy_;61 51 }; 62 52 } -
code/trunk/src/orxonox/infos/PlayerInfo.cc
r8706 r8891 235 235 236 236 this->controllableEntity_->setController(0); 237 this->controllableEntity_->destroyHud(); // HACK-ish 237 if(this->isHumanPlayer()) // TODO: Multiplayer? 238 this->controllableEntity_->destroyHud(); // HACK-ish 238 239 239 240 // this->controllableEntity_ = this->previousControllableEntity_.back(); … … 248 249 249 250 // HACK-ish 250 if(this->controllableEntity_ != NULL )251 if(this->controllableEntity_ != NULL && this->isHumanPlayer()) 251 252 this->controllableEntity_->createHud(); 252 253 -
code/trunk/src/orxonox/weaponsystem/WeaponSlot.h
r5781 r8891 35 35 namespace orxonox 36 36 { 37 /** 38 @brief 39 The a WeaponSlot defines where a @ref orxonox::Weapon "Weapon" is placed on a pawn. (A WeaponSlot is a StaticEntity) 40 In a WeaponSlot there can be only one "Weapon", but a Weapon can have several @ref orxonox::WeaponMode "WeaponModes". 41 A WeaponMode is what one intuitively imagines as weapon. (E.g. RocketFire, LightningGun, LaserFire are weaponmodes) 42 43 A WeaponSlot is created in XML (in a weaponsettings file), which can be done in the following fashion: 44 @code 45 <weaponslots> 46 <WeaponSlot position="-15.0,-1.5,0" /> 47 <WeaponSlot position=" 15.0,-1.5,0" /> 48 <WeaponSlot position=" 0, 0,0" /> 49 </weaponslots> 50 51 @author 52 Martin Polak 53 54 @ingroup Weaponsystem 55 */ 37 56 class _OrxonoxExport WeaponSlot : public StaticEntity 38 57 { -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r8858 r8891 67 67 this->camera_ = 0; 68 68 this->xmlcontroller_ = 0; 69 this->controller_ = 0;69 //this->controller_ = 0; 70 70 this->reverseCamera_ = 0; 71 71 this->bDestroyWhenPlayerLeft_ = false; … … 74 74 this->bMouseLook_ = false; 75 75 this->mouseLookSpeed_ = 200; 76 this->bIsRocket_ = false; 76 77 77 78 this->server_position_ = Vector3::ZERO; … … 189 190 return counter; 190 191 } 191 192 192 193 bool ControllableEntity::setCameraPosition(unsigned int index) 193 194 { … … 309 310 } 310 311 312 void ControllableEntity::setController(Controller* val) 313 { 314 this->controller_ = val; 315 } 316 311 317 void ControllableEntity::setTarget( WorldEntity* target ) 312 318 { -
code/trunk/src/orxonox/worldentities/ControllableEntity.h
r8706 r8891 99 99 */ 100 100 virtual void boost(bool bBoost) {} 101 101 102 102 virtual void greet() {} 103 103 virtual void switchCamera(); … … 155 155 156 156 inline Controller* getController() const 157 { return this->controller_ ; }158 inline void setController(Controller* val)159 { this->controller_ = val; } 157 { return this->controller_.get(); } 158 void setController(Controller* val); 159 160 160 161 161 virtual void setTarget( WorldEntity* target ); … … 163 163 { return this->target_.get(); } 164 164 void setTargetInternal( uint32_t targetID ); 165 inline bool getRocket() const 166 { return this-> bIsRocket_; } 165 167 166 168 protected: … … 181 183 182 184 Ogre::SceneNode* cameraPositionRootNode_; 185 bool bIsRocket_; //Workaround to see, if the controllable entity is a Rocket. 183 186 184 187 private: … … 234 237 std::string cameraPositionTemplate_; 235 238 Controller* xmlcontroller_; 236 Controller*controller_;239 WeakPtr<Controller> controller_; 237 240 CameraPosition* reverseCamera_; 238 241 WeakPtr<WorldEntity> target_; -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r8855 r8891 93 93 94 94 this->isHumanShip_ = this->hasLocalController(); 95 95 96 96 this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition 97 97 } … … 450 450 this->isHumanShip_ = true; 451 451 } 452 453 void Pawn::changedActivity(void) 454 { 455 SUPER(Pawn, changedActivity); 456 457 this->setRadarVisibility(this->isActive()); 458 } 459 460 void Pawn::changedVisibility(void) 461 { 462 SUPER(Pawn, changedVisibility); 463 //this->setVisible(this->isVisible()); 464 this->setRadarVisibility(this->isVisible()); 465 } 466 452 467 } -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r8855 r8891 170 170 virtual const Vector3& getCarrierPosition(void) const 171 171 { return this->getWorldPosition(); }; 172 virtual void changedActivity(void); //!< To enable radarviewability when the activity is changed 173 virtual void changedVisibility(void); //!< To enable proper radarviewability when the visibility is changed 172 174 173 175 protected: … … 195 197 float maxHealth_; 196 198 float initialHealth_; 197 199 198 200 float shieldHealth_; 199 201 float maxShieldHealth_; -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r8858 r8891 298 298 } 299 299 300 /**301 @brief302 Add an Engine to the SpaceShip.303 @param engine304 A pointer to the Engine to be added.305 */306 300 void SpaceShip::addEngine(orxonox::Engine* engine) 307 301 { … … 504 498 void SpaceShip::resetCamera() 505 499 { 506 Camera *camera = this->getCamera(); 507 if (camera == 0) 508 { 509 orxout(internal_warning) << "Failed to reset camera!" << endl; 510 return; 511 } 512 513 this->shakeDt_ = 0.0f; 514 camera->setPosition(this->cameraOriginalPosition_); 515 camera->setOrientation(this->cameraOriginalOrientation_); 500 if(this->hasLocalController() && this->hasHumanController()) 501 { 502 Camera *camera = this->getCamera(); 503 if (camera == 0) 504 { 505 orxout(internal_warning) << "Failed to reset camera!" << endl; 506 return; 507 } 508 this->shakeDt_ = 0.0f; 509 camera->setPosition(this->cameraOriginalPosition_); 510 camera->setOrientation(this->cameraOriginalOrientation_); 511 } 516 512 } 517 513
Note: See TracChangeset
for help on using the changeset viewer.