Changeset 10872
- Timestamp:
- Nov 27, 2015, 9:45:24 AM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10871 r10872 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" /> … … 62 62 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 63 63 P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped --> 64 64 <!-- 65 65 <Model mesh="cube.mesh" scale=8 position="0,0,0" /> 66 66 … … 124 124 </SpaceShip> 125 125 126 126 --> 127 127 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS --> 128 128 <!-- HERE STARTS DEMO FOR FIGHTING --> … … 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
r10871 r10872 229 229 void ActionpointController::executeActionpoint() 230 230 { 231 if (this->bLoop_) 232 { 233 if (!this->loopActionpoints_.empty()) 234 { 235 this->action_ = this->loopActionpoints_.back().action; 236 switch ( this->action_ ) 237 { 238 case Action::FIGHT: 231 Point p; 232 if (this->bLoop_ && !loopActionpoints_.empty()) 233 { 234 p = loopActionpoints_.back(); 235 } 236 else if (this->bLoop_) 237 { 238 this->bLoop_ = false; 239 return; 240 } 241 else if (!this->bLoop_ && !parsedActionpoints_.empty()) 242 { 243 p = parsedActionpoints_.back(); 244 } 245 else 246 { 247 this->setTarget(0); 248 this->setTargetPosition(this->getControllableEntity()->getWorldPosition()); 249 this->action_ = Action::NONE; 250 return; 251 } 252 if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop) 253 { 254 //MOVES all points that are in loop to a loop vector 255 this->fillLoop(); 256 this->bLoop_ = true; 257 executeActionpoint(); 258 return; 259 } 260 this->action_ = p.action; 261 switch ( this->action_ ) 262 { 263 case Action::FIGHT: 264 { 265 std::string targetName = p.name; 266 if (targetName == "") 267 { 268 break; 269 } 270 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 271 { 272 if (CommonController::getName(*itP) == targetName) 239 273 { 240 std::string targetName = this->loopActionpoints_.back().name; 241 if (targetName == "") 274 this->setTarget (static_cast<ControllableEntity*>(*itP)); 275 } 276 } 277 break; 278 } 279 case Action::FLY: 280 { 281 this->setTargetPosition( p.position ); 282 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 283 { 284 this->nextActionpoint(); 285 this->executeActionpoint(); 286 } 287 break; 288 } 289 case Action::PROTECT: 290 { 291 292 std::string protectName = p.name; 293 if (protectName == "reservedKeyword:human") 294 { 295 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 296 { 297 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController())) 242 298 { 243 break;299 this->setProtect (static_cast<ControllableEntity*>(*itP)); 244 300 } 245 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 301 } 302 } 303 else 304 { 305 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 306 { 307 if (CommonController::getName(*itP) == protectName) 246 308 { 247 if (CommonController::getName(*itP) == targetName) 248 { 249 this->setTarget (static_cast<ControllableEntity*>(*itP)); 250 } 251 } 252 break; 309 this->setProtect (static_cast<ControllableEntity*>(*itP)); 310 } 311 } 312 } 313 if (!this->getProtect()) 314 { 315 this->nextActionpoint(); 316 this->executeActionpoint(); 317 } 318 break; 319 } 320 case Action::NONE: 321 { 322 break; 323 } 324 case Action::FIGHTALL: 325 { 326 break; 327 } 328 case Action::ATTACK: 329 { 330 std::string targetName = p.name; 331 332 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 333 { 334 if (CommonController::getName(*itP) == targetName) 335 { 336 this->setTarget (static_cast<ControllableEntity*>(*itP)); 253 337 } 254 case Action::FLY: 255 { 256 this->setTargetPosition( this->loopActionpoints_.back().position ); 257 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 258 { 259 this->nextActionpoint(); 260 this->executeActionpoint(); 261 } 262 break; 263 } 264 case Action::PROTECT: 265 { 266 std::string protectName = this->loopActionpoints_.back().name; 267 if (protectName == "reservedKeyword:human") 268 { 269 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 270 { 271 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController())) 272 { 273 this->setProtect (static_cast<ControllableEntity*>(*itP)); 274 } 275 } 276 } 277 else 278 { 279 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 280 { 281 if (CommonController::getName(*itP) == protectName) 282 { 283 this->setProtect (static_cast<ControllableEntity*>(*itP)); 284 } 285 } 286 } 287 if (!this->getProtect()) 288 { 289 this->nextActionpoint(); 290 this->executeActionpoint(); 291 } 292 break; 293 } 294 case Action::NONE: 295 { 296 break; 297 } 298 case Action::FIGHTALL: 299 { 300 break; 301 } 302 case Action::ATTACK: 303 { 304 std::string targetName = this->loopActionpoints_.back().name; 305 306 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 307 { 308 if (CommonController::getName(*itP) == targetName) 309 { 310 this->setTarget (static_cast<ControllableEntity*>(*itP)); 311 } 312 } 313 if (!this->hasTarget()) 314 { 315 this->nextActionpoint(); 316 this->executeActionpoint(); 317 } 318 break; 319 } 320 default: 321 { 322 break; 323 } 324 325 } 326 } 327 else 328 { 329 this->bLoop_ = false; 330 } 331 } 332 else 333 { 334 if (!this->parsedActionpoints_.empty()) 335 { 336 if (this->parsedActionpoints_.back().inLoop) 337 { 338 //MOVES all points that are in loop to a loop vector 339 this->fillLoop(); 340 this->bLoop_ = true; 341 executeActionpoint(); 342 return; 343 } 344 this->action_ = this->parsedActionpoints_.back().action; 345 switch ( this->action_ ) 346 { 347 case Action::FIGHT: 348 { 349 std::string targetName = this->parsedActionpoints_.back().name; 350 if (targetName == "") 351 { 352 break; 353 } 354 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 355 { 356 if (CommonController::getName(*itP) == targetName) 357 { 358 this->setTarget (static_cast<ControllableEntity*>(*itP)); 359 } 360 } 361 break; 362 } 363 case Action::FLY: 364 { 365 this->setTargetPosition( this->parsedActionpoints_.back().position ); 366 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 367 { 368 this->nextActionpoint(); 369 this->executeActionpoint(); 370 } 371 break; 372 } 373 case Action::PROTECT: 374 { 375 376 std::string protectName = this->parsedActionpoints_.back().name; 377 if (protectName == "reservedKeyword:human") 378 { 379 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 380 { 381 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController())) 382 { 383 this->setProtect (static_cast<ControllableEntity*>(*itP)); 384 } 385 } 386 } 387 else 388 { 389 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 390 { 391 if (CommonController::getName(*itP) == protectName) 392 { 393 this->setProtect (static_cast<ControllableEntity*>(*itP)); 394 } 395 } 396 } 397 if (!this->getProtect()) 398 { 399 this->nextActionpoint(); 400 this->executeActionpoint(); 401 } 402 break; 403 } 404 case Action::NONE: 405 { 406 break; 407 } 408 case Action::FIGHTALL: 409 { 410 break; 411 } 412 case Action::ATTACK: 413 { 414 std::string targetName = this->parsedActionpoints_.back().name; 415 416 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 417 { 418 if (CommonController::getName(*itP) == targetName) 419 { 420 this->setTarget (static_cast<ControllableEntity*>(*itP)); 421 } 422 } 423 if (!this->hasTarget()) 424 { 425 this->nextActionpoint(); 426 this->executeActionpoint(); 427 } 428 break; 429 } 430 default: 431 break; 432 } 433 } 434 435 else 436 { 437 this->setTarget(0); 438 this->setTargetPosition(this->getControllableEntity()->getWorldPosition()); 439 this->action_ = Action::NONE; 440 } 441 } 442 } 338 } 339 if (!this->hasTarget()) 340 { 341 this->nextActionpoint(); 342 this->executeActionpoint(); 343 } 344 break; 345 } 346 default: 347 break; 348 } 349 350 } 443 351 444 352 … … 613 521 this->parsedActionpoints_ = vector; 614 522 this->loopActionpoints_ = loop; 615 this->bLoop_ = this->bLoop_;523 this->bLoop_ = b; 616 524 this->bTakenOver_ = true; 617 525 // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
Note: See TracChangeset
for help on using the changeset viewer.