Changeset 10906
- Timestamp:
- Nov 30, 2015, 9:34:54 PM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10903 r10906 157 157 <!-- HERE STARTS DEMO FOR FIGHTING --> 158 158 159 159 <!-- 160 160 <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1"> 161 161 <templates> … … 195 195 </controller> 196 196 </SpaceShip> 197 <SpaceShip position="-5000, 1500, -1000" lookat="0,0,0" team=0 name="d1s1d1"> 198 <templates> 199 <Template link=spaceshipassff /> 200 </templates> 201 <controller> 202 <DivisionController team=0 formationMode="WALL"> 203 204 </DivisionController> 205 </controller> 206 </SpaceShip> 207 <SpaceShip position="-5000, 1900, -1000" lookat="0,0,0" team=0 name="d1s1s1"> 208 <templates> 209 <Template link=spaceshipassff /> 210 </templates> 211 <controller> 212 <SectionController team=0> 213 </SectionController> 214 </controller> 215 </SpaceShip> 216 <SpaceShip position="-5000, 2100, -1000" lookat="0,0,0" team=0 name="d1s1w1"> 217 <templates> 218 <Template link=spaceshipassff /> 219 </templates> 220 <controller> 221 <WingmanController team=0> 222 </WingmanController> 223 </controller> 224 </SpaceShip> 225 <SpaceShip position="-5000, 2400, -1000" lookat="0,0,0" team=0 name="d1s1w2"> 226 <templates> 227 <Template link=spaceshipassff /> 228 </templates> 229 <controller> 230 <WingmanController team=0> 231 </WingmanController> 232 </controller> 233 </SpaceShip> 197 234 198 235 <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 name="d2sd1"> … … 225 262 </SpaceShip> 226 263 <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1 name="d2sw2"> 264 <templates> 265 <Template link=spaceshipassff /> 266 </templates> 267 <controller> 268 <WingmanController team=1> 269 </WingmanController> 270 </controller> 271 </SpaceShip> 272 <SpaceShip position="1000, -1500, 1000" lookat="0,0,0" team=1 name="d2s1d1"> 273 <templates> 274 <Template link=spaceshipassff /> 275 </templates> 276 <controller> 277 <DivisionController team=1 formationMode="WALL"> 278 279 </DivisionController> 280 </controller> 281 </SpaceShip> 282 <SpaceShip position="1000, -1900, 1000" lookat="0,0,0" team=1 name="d2s1s1"> 283 <templates> 284 <Template link=spaceshipassff /> 285 </templates> 286 <controller> 287 <SectionController team=1> 288 </SectionController> 289 </controller> 290 </SpaceShip> 291 <SpaceShip position="1000, -2100, 1000" lookat="0,0,0" team=1 name="d2s1w1"> 292 <templates> 293 <Template link=spaceshipassff /> 294 </templates> 295 <controller> 296 <WingmanController team=1> 297 </WingmanController> 298 </controller> 299 </SpaceShip> --> 300 <SpaceShip position="1000, -2400, 1000" lookat="0,0,0" team=1 name="d2s1w2"> 227 301 <templates> 228 302 <Template link=spaceshipassff /> -
code/branches/campaignHS15/data/levels/shuttleRetaliation.oxw
r10904 r10906 42 42 <?lua 43 43 44 enemies = 445 allies = 444 enemies = 2 45 allies = 2 46 46 47 47 radSector = 12000 -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10903 r10906 53 53 this->squaredaccuracy_ = 2500; 54 54 this->bFirstTick_ = true; 55 55 this->bStartedDodging_ = false; 56 this->timeDodged_ = 0; 56 57 RegisterObject(ActionpointController); 57 58 … … 78 79 this->timeout_ -= dt; 79 80 } 81 if (this->bStartedDodging_) 82 { 83 this->timeDodged_ += dt; 84 if (this->timeDodged_ > 2.0f) 85 { 86 this->bStartedDodging_ = false; 87 this->timeDodged_ = 0; 88 } 89 } 90 maneuverCounter_ += dt; 91 if (maneuverCounter_ > 6.0f) 92 maneuverCounter_ = 0; 80 93 if (timeout_ <= 0) 81 94 this->bFiredRocket_ = false; … … 110 123 this->bFirstTick_ = false; 111 124 } 112 125 if (this->hasTarget()) 126 { 127 this->maneuver(); 128 if (static_cast<int>(this->maneuverCounter_*100) % 3 == 0) 129 this->bShooting_ = this->canFire(); 130 } 113 131 SUPER(ActionpointController, tick, dt); 114 132 } … … 123 141 this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp; 124 142 this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth(); 143 125 144 // if (this->actionCounter_ % 2 == 0) 126 145 //No action -> pop one from stack … … 236 255 } 237 256 } 238 if (this->hasTarget()) 239 { 240 this->maneuver(); 241 this->bShooting_ = this->canFire(); 257 242 258 // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length()); 243 259 // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_) … … 252 268 // //----fire if you can---- 253 269 // this->bShooting_ = this->canFire(); 254 }270 255 271 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; 256 272 -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
r10903 r10906 118 118 if ( !this->target_ || !this->getControllableEntity()) 119 119 return; 120 maneuverCounter_++; 121 if (maneuverCounter_ > 5) 122 maneuverCounter_ = 0; 120 123 121 124 122 Vector3 thisPosition = this->getControllableEntity()->getWorldPosition(); … … 128 126 float diffLength = diffVector.length(); 129 127 Vector3 diffUnit = diffVector/diffLength; 130 bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/1 5.0f)128 bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/10.0f) 131 129 || this->deltaHp < 0; 132 130 … … 140 138 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f); 141 139 } 142 //too close? How do u expect to dodge anything? Just attack! 140 else 141 { 142 this->bKeepFormation_ = false; 143 // if (this->actionCounter_ % 3 == 0) 144 if (maneuverCounter_ <= 1.2) 145 { 146 // orxout(internal_error) << "attacking" << endl; 147 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f); 148 return; 149 } 150 else if (bTargetIsLookingAtThis || diffLength < 700.0f) 151 { 152 // orxout(internal_error) << "dodging" << endl; 153 if (!this->bStartedDodging_) 154 { 155 this->bStartedDodging_ = true; 156 dodge(thisPosition, diffLength, diffUnit); 157 } 158 } 159 else 160 { 161 if (diffLength < 1000) 162 { 163 // orxout(internal_error) << "looking" << endl; 164 this->stopMoving(); 165 this->startLookingAtTarget(); 166 167 } 168 else 169 { 170 // orxout(internal_error) << "closing up" << endl; 171 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f); 172 } 173 } 174 } 175 /*//too close? How do u expect to dodge anything? Just attack! 143 176 else if (diffLength < 1000) 144 177 { … … 146 179 147 180 //at this point, just look and shoot 148 if (diffLength < 500)181 if (diffLength < 1000) 149 182 { 150 183 this->stopMoving(); 151 184 this->startLookingAtTarget(); 185 152 186 } 153 187 else … … 160 194 { 161 195 this->bKeepFormation_ = false; 162 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);196 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 900.0f); 163 197 } 164 198 //That's unfortunate, he is looking and probably shooting... try to dodge what we can... … … 168 202 if (maneuverCounter_ == 0) 169 203 { 170 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);204 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 900.0f); 171 205 return; 172 206 } 173 207 if (this->actionCounter_ % 3 == 0) 174 dodge(thisPosition, diff Unit);175 } 208 dodge(thisPosition, diffLength, diffUnit); 209 }*/ 176 210 } 177 211 void FightingController::dodgeTowards (Vector3& position) … … 200 234 this->boostControl(); 201 235 } 202 void FightingController::dodge(const Vector3& thisPosition, Vector3& diffUnit)236 void FightingController::dodge(const Vector3& thisPosition, float diffLength, Vector3& diffUnit) 203 237 { 204 238 //d.x*x + d.y*y + d.z*z == 0 205 239 //z = 1/d.z * (-d.y*y - d.x * x) 206 float x = CommonController::randomInRange ( 100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);207 float y = CommonController::randomInRange ( 100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);240 float x = CommonController::randomInRange (300, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1); 241 float y = CommonController::randomInRange (300, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1); 208 242 float z = diffUnit.z == 0 ? 0 : (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y); 209 this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : diffUnit * 100.0f)); 243 if (diffLength < 150.0f) 244 { 245 this->setTargetPosition(this->positionOfTarget_ + Vector3(z,x,y)); 246 } 247 else 248 { 249 this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : 250 (diffLength < 700.0f ? -diffUnit*700.0f : diffUnit * 50.0f))); 251 252 } 210 253 this->boostControl(); 211 254 … … 225 268 } 226 269 227 return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 20.0f);270 return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 10.0f); 228 271 } 229 272 -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
r10898 r10906 67 67 void maneuver(); //<! sets this->targetPosition_, which is a Vector3 of where this ship flies. Decision is made based on 68 68 //<! the distance to enemy, if being attacked, dodge() is called, otherwise ship just flies towards this->target_. 69 void dodge(const Vector3& thisPosition, Vector3& diffUnit); //<! choose a random Vector3 perpendicular to the difference vector between69 void dodge(const Vector3& thisPosition, float diffLength, Vector3& diffUnit); //<! choose a random Vector3 perpendicular to the difference vector between 70 70 //<! this and target_ plus or minus some amount in difference vector direction, 71 71 //<! depending on whether it is better to close up or survive. … … 84 84 int attackRange_; 85 85 bool bShooting_; 86 int maneuverCounter_;86 float maneuverCounter_; 87 87 bool bLookAtTarget_; 88 88 float deltaHp; 89 89 float previousHp; 90 bool bStartedDodging_; 91 float timeDodged_; 90 92 //WEAPONSYSTEM DATA 91 93 int rocketsLeft_; -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10888 r10906 125 125 if (this->hasTarget()) 126 126 { 127 this->maneuver();128 this->bShooting_ = this->canFire();127 // this->maneuver(); 128 // this->bShooting_ = this->canFire(); 129 129 // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length()); 130 130 // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_) -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10888 r10906 112 112 if (this->hasTarget()) 113 113 { 114 this->maneuver();115 this->bShooting_ = this->canFire();114 // this->maneuver(); 115 // this->bShooting_ = this->canFire(); 116 116 // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length()); 117 117 // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
Note: See TracChangeset
for help on using the changeset viewer.