Changeset 10883
- Timestamp:
- Nov 28, 2015, 11:46:05 AM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10882 r10883 35 35 36 36 <!-- HERE STARTS DEMO FOR THE "WAYPOINTS" --> 37 37 <!-- 38 38 <Model mesh="cube.mesh" scale=8 position=" 0,2000,-600" /> 39 39 <Model mesh="cube.mesh" scale=8 position=" 0,2000,-800" /> … … 57 57 </controller> 58 58 </SpaceShip> 59 59 --> 60 60 <!-- HERE ENDS DEMO FOR THE "WAYPOINTS" --> 61 61 … … 128 128 <!-- HERE STARTS DEMO FOR FIGHTING --> 129 129 <!-- 130 <SpaceShip position="- 2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">130 <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="ss2"> 131 131 <templates> 132 132 <Template link=spaceshipassff /> … … 140 140 </controller> 141 141 </SpaceShip> 142 <SpaceShip position="- 2000, 1900, -1000" lookat="0,0,0" team=0>142 <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0> 143 143 <templates> 144 144 <Template link=spaceshipassff /> … … 149 149 </controller> 150 150 </SpaceShip> 151 <SpaceShip position="- 2000, 2100, -1000" lookat="0,0,0" team=0>152 <templates> 153 <Template link=spaceshipassff /> 154 </templates> 155 <controller> 156 <WingmanController team=0> 157 </WingmanController> 158 </controller> 159 </SpaceShip> 160 <SpaceShip position="- 2000, 2400, -1000" lookat="0,0,0" team=0>151 <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0> 152 <templates> 153 <Template link=spaceshipassff /> 154 </templates> 155 <controller> 156 <WingmanController team=0> 157 </WingmanController> 158 </controller> 159 </SpaceShip> 160 <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0> 161 161 <templates> 162 162 <Template link=spaceshipassff /> … … 210 210 <!-- HERE ENDS DEMO FOR FIGHTING --> 211 211 <!-- HERE STARTS DEMO FOR FORMATIONS --> 212 <!--212 213 213 <Model mesh="cube.mesh" scale=8 position=" 0,2000, 0" /> 214 214 <Model mesh="cube.mesh" scale=8 position=" 0,2000,-2000" /> … … 259 259 </controller> 260 260 </SpaceShip> 261 -->261 262 262 <!-- HERE ENDS DEMO FOR FORMATIONS --> 263 263 <!-- -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10882 r10883 41 41 ActionpointController::ActionpointController(Context* context) : FightingController(context) 42 42 { 43 this->actionCounter_ = 0; 43 44 this->bInLoop_ = false; 44 45 this->bLoop_ = false; … … 419 420 return; 420 421 // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl; 421 if (this->actionCounter_ % 5== 0)422 if (this->actionCounter_ % 2 == 0) 422 423 this->startAttackingEnemiesThatAreClose(); 423 424 //No action -> pop one from stack -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10882 r10883 39 39 { 40 40 RegisterObject(DivisionController); 41 this->actionCounter_ = 0;42 41 this->setFormationMode(FormationMode::DIAMOND); 43 42 this->target_ = 0; -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
r10880 r10883 38 38 FightingController::FightingController( Context* context ): FlyingController( context ) 39 39 { 40 this->attackRange_ = 2 500;40 this->attackRange_ = 2000; 41 41 this->stopLookingAtTarget(); 42 42 … … 129 129 130 130 //too far? well, come closer then 131 if ( diffLength > this->attackRange_ ) 132 { 131 if (diffLength > this->attackRange_) 132 { 133 this->spread_ = 300; 134 this->formationMode_ = FormationMode::WALL; 135 this->bKeepFormation_ = true; 136 133 137 this->setTargetPosition( this->positionOfTarget_ ); 134 138 } … … 136 140 else if ( diffLength < 500 ) 137 141 { 142 this->bKeepFormation_ = false; 143 138 144 //at this point, just look and shoot 139 145 if ( diffLength < 250 ) … … 150 156 else if ( !bTargetIsLookingAtThis ) 151 157 { 158 this->bKeepFormation_ = false; 152 159 this->setTargetPosition( this->positionOfTarget_ ); 153 160 } … … 155 162 else 156 163 { 164 this->bKeepFormation_ = false; 157 165 if (maneuverCounter_ == 0) 158 166 { -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
r10877 r10883 49 49 ControllableEntity* getTarget() 50 50 { return this->target_; } 51 bool bKeepFormation_; 51 52 52 53 protected: -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10881 r10883 124 124 else if (myDivisionLeader_) 125 125 { 126 switch (myDivisionLeader_->getAction()) 127 { 128 case Action::FIGHT: 129 { 130 if (!this->hasTarget()) 131 { 132 this->chooseTarget(); 133 } 134 break; 135 } 136 case Action::FIGHTALL: 137 { 138 if (!this->hasTarget()) 139 { 140 this->chooseTarget(); 141 } 142 break; 143 } 144 case Action::ATTACK: 145 { 146 if (!this->hasTarget()) 147 { 148 this->chooseTarget(); 149 } 150 break; 151 } 152 default: 153 { 154 //formation flight is executed in tick 155 ControllableEntity* myEntity = this->getControllableEntity(); 156 Vector3 myPosition = myEntity->getWorldPosition(); 157 if (!this->myDivisionLeader_) 158 { 159 return; 160 } 161 ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity(); 162 Quaternion orient = leaderEntity->getWorldOrientation(); 163 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 164 165 Vector3 targetRelativePosition = getFormationPosition(); 166 if (!this->myDivisionLeader_) 167 { 168 return; 169 } 170 Vector3 targetAbsolutePosition = 171 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 172 + (orient* (targetRelativePosition))); 173 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function. 174 if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_) 175 this->setAction (Action::FLY, targetAbsolutePosition, orient); 126 if (this->myDivisionLeader_->bKeepFormation_ || !(this->myDivisionLeader_->getAction() == Action::FIGHT 127 || this->myDivisionLeader_->getAction() == Action::FIGHTALL 128 || this->myDivisionLeader_->getAction() == Action::ATTACK)) 129 { 130 ControllableEntity* myEntity = this->getControllableEntity(); 131 Vector3 myPosition = myEntity->getWorldPosition(); 132 if (!this->myDivisionLeader_) 133 { 134 return; 135 } 136 ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity(); 137 Quaternion orient = leaderEntity->getWorldOrientation(); 138 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 139 140 Vector3 targetRelativePosition = getFormationPosition(); 141 if (!this->myDivisionLeader_) 142 { 143 return; 144 } 145 Vector3 targetAbsolutePosition = 146 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 147 + (orient* (targetRelativePosition))); 148 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function. 149 if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_) 150 this->setAction (Action::FLY, targetAbsolutePosition, orient); 151 else 152 this->setAction (Action::FLY, targetAbsolutePosition); 153 154 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 155 { 156 this->boostControl(); 157 } 158 else 159 { 160 this->getControllableEntity()->boost(false); 161 } 162 } 176 163 else 177 this->setAction (Action::FLY, targetAbsolutePosition); 178 179 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 180 { 181 this->boostControl(); 182 } 183 else 184 { 185 this->getControllableEntity()->boost(false); 186 } 187 } 188 } 189 if (this->hasTarget()) 190 { 191 //----choose where to go---- 192 this->maneuver(); 193 //----fire if you can---- 194 this->bShooting_ = this->canFire(); 195 } 164 { 165 switch (myDivisionLeader_->getAction()) 166 { 167 case Action::FIGHT: 168 { 169 if (!this->hasTarget()) 170 { 171 this->chooseTarget(); 172 } 173 break; 174 } 175 case Action::FIGHTALL: 176 { 177 if (!this->hasTarget()) 178 { 179 this->chooseTarget(); 180 } 181 break; 182 } 183 case Action::ATTACK: 184 { 185 if (!this->hasTarget()) 186 { 187 this->chooseTarget(); 188 } 189 break; 190 } 191 default: 192 { 193 //formation flight is executed in tick 194 } 195 } 196 if (this->hasTarget()) 197 { 198 //----choose where to go---- 199 this->maneuver(); 200 //----fire if you can---- 201 this->bShooting_ = this->canFire(); 202 } 203 } 204 205 196 206 } 197 207 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; … … 263 273 { 264 274 this->setFormationMode( this->myDivisionLeader_->getFormationMode() ); 275 this->spread_ = this->myDivisionLeader_->getSpread(); 265 276 Vector3* targetRelativePosition; 266 277 switch (this->formationMode_){ -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10881 r10883 105 105 else if (this->myLeader_) 106 106 { 107 switch (this->myLeader_->getAction()) 108 { 109 case Action::FIGHT: 110 { 111 if (!this->hasTarget()) 112 { 113 this->setTarget(this->myLeader_->getTarget()); 114 } 115 break; 116 } 117 case Action::FIGHTALL: 118 { 119 if (!this->hasTarget()) 120 { 121 this->setTarget(this->myLeader_->getTarget()); 122 } 123 break; 124 } 125 case Action::ATTACK: 126 { 127 if (!this->hasTarget()) 128 { 129 this->setTarget(this->myLeader_->getTarget()); 130 } 131 break; 132 } 133 default: 134 { 107 if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT || this->myLeader_->getAction() == Action::FIGHTALL 108 || this->myLeader_->getAction() == Action::ATTACK)) 109 { 110 ControllableEntity* myEntity = this->getControllableEntity(); 111 Vector3 myPosition = myEntity->getWorldPosition(); 112 if (!this->myLeader_) 113 { 114 return; 115 } 116 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity(); 117 Quaternion orient = leaderEntity->getWorldOrientation(); 118 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 119 Vector3 targetRelativePosition = getFormationPosition(); 120 if (!this->myLeader_) 121 { 122 return; 123 } 124 Vector3 targetAbsolutePosition = 125 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 126 + (orient* (targetRelativePosition))); 127 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function. 128 if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_) 129 this->setAction (Action::FLY, targetAbsolutePosition, orient); 130 else 131 this->setAction (Action::FLY, targetAbsolutePosition); 132 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 133 { 134 this->boostControl(); 135 } 136 else 137 { 138 this->getControllableEntity()->boost(false); 139 } 140 } 141 else 142 { 143 switch (this->myLeader_->getAction()) 144 { 145 case Action::FIGHT: 146 { 147 if (!this->hasTarget()) 148 { 149 this->setTarget(this->myLeader_->getTarget()); 150 } 151 break; 152 } 153 case Action::FIGHTALL: 154 { 155 if (!this->hasTarget()) 156 { 157 this->setTarget(this->myLeader_->getTarget()); 158 } 159 break; 160 } 161 case Action::ATTACK: 162 { 163 if (!this->hasTarget()) 164 { 165 this->setTarget(this->myLeader_->getTarget()); 166 } 167 break; 168 } 169 default: 170 { 135 171 136 ControllableEntity* myEntity = this->getControllableEntity(); 137 Vector3 myPosition = myEntity->getWorldPosition(); 138 if (!this->myLeader_) 139 { 140 return; 141 } 142 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity(); 143 Quaternion orient = leaderEntity->getWorldOrientation(); 144 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 145 Vector3 targetRelativePosition = getFormationPosition(); 146 if (!this->myLeader_) 147 { 148 return; 149 } 150 Vector3 targetAbsolutePosition = 151 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 152 + (orient* (targetRelativePosition))); 153 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function. 154 if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_) 155 this->setAction (Action::FLY, targetAbsolutePosition, orient); 156 else 157 this->setAction (Action::FLY, targetAbsolutePosition); 158 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 159 { 160 this->boostControl(); 161 } 162 else 163 { 164 this->getControllableEntity()->boost(false); 165 } 166 } 167 } 168 if (this->hasTarget()) 169 { 170 //----choose where to go---- 171 this->maneuver(); 172 //----fire if you can---- 173 this->bShooting_ = this->canFire(); 174 } 172 } 173 } 174 if (this->hasTarget()) 175 { 176 //----choose where to go---- 177 this->maneuver(); 178 //----fire if you can---- 179 this->bShooting_ = this->canFire(); 180 } 181 } 182 183 175 184 } 176 185 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; … … 182 191 this->setFormationMode( this->myLeader_->getFormationMode() ); 183 192 Vector3* targetRelativePosition; 184 193 this->spread_ = this->myLeader_->getSpread(); 185 194 if (this->myLeader_->getIdentifier()->getName() == "DivisionController") 186 195 {
Note: See TracChangeset
for help on using the changeset viewer.