[Orxonox-commit 4060] r8731 - code/branches/ai2/src/orxonox/controllers
jo at orxonox.net
jo at orxonox.net
Tue Jul 5 22:39:51 CEST 2011
Author: jo
Date: 2011-07-05 22:39:50 +0200 (Tue, 05 Jul 2011)
New Revision: 8731
Modified:
code/branches/ai2/src/orxonox/controllers/AIController.cc
Log:
Narrowed down: Bug triggered in the doFire() function in ArtificialController.cc
Modified: code/branches/ai2/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/ai2/src/orxonox/controllers/AIController.cc 2011-07-05 20:16:47 UTC (rev 8730)
+++ code/branches/ai2/src/orxonox/controllers/AIController.cc 2011-07-05 20:39:50 UTC (rev 8731)
@@ -207,11 +207,43 @@
float random;
float maxrand = 100.0f / ACTION_INTERVAL;
+ if(this->mode_ == DEFAULT)
+ {
+ if (this->state_ == MASTER)
+ {
+ if (this->specificMasterAction_ == NONE)
+ {
+ if (this->target_)
+ {
+ if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
+ this->forgetTarget();
+ else this->aimAtTarget();
+ }
- if (this->state_ == MASTER)
- {
- if (this->specificMasterAction_ == NONE)
+ if (this->bHasTargetPosition_)
+ this->moveToTargetPosition();
+
+ if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
+ this->getControllableEntity()->fire(0);
+ }
+
+ if (this->specificMasterAction_ == TURN180)
+ this->turn180();
+
+ if (this->specificMasterAction_ == SPIN)
+ this->spin();
+ if (this->specificMasterAction_ == FOLLOW)
+ this->follow();
+ }
+
+ if (this->state_ == SLAVE)
{
+ if (this->bHasTargetPosition_)
+ this->moveToTargetPosition();
+ }
+
+ if (this->state_ == FREE)
+ {
if (this->target_)
{
if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
@@ -225,40 +257,29 @@
if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
this->getControllableEntity()->fire(0);
}
-
- if (this->specificMasterAction_ == TURN180)
- this->turn180();
-
- if (this->specificMasterAction_ == SPIN)
- this->spin();
- if (this->specificMasterAction_ == FOLLOW)
- this->follow();
- }
-
- if (this->state_ == SLAVE)
- {
-
- if (this->bHasTargetPosition_)
- this->moveToTargetPosition();
-
- }
-
- if (this->state_ == FREE)
- {
- if (this->target_)
+ }//END_OF DEFAULT MODE
+ else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant.
+ { //Vector-implementation: mode_.back() == ROCKET;
+ ControllableEntity *controllable = this->getControllableEntity();
+ if(controllable)
{
- if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
- this->forgetTarget();
- else this->aimAtTarget();
+ if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over.
+ {
+ this->follow(); //TODO: CHECK: does follow make the bot crash into the target_ ?
+ this->timeout_ -= dt;
+ if((timeout_< 0)||(!target_))//Check if the timeout is over or target died.
+ {
+ controllable->fire(0);//kill the rocket
+ this->setPreviousMode();//get out of rocket mode
+ }
+ }
+ else
+ this->setPreviousMode();//no rocket entity -> get out of rocket mode
}
+ else
+ this->setPreviousMode();//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode
+ }//END_OF ROCKET MODE
- if (this->bHasTargetPosition_)
- this->moveToTargetPosition();
-
- if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
- this->getControllableEntity()->fire(0);
- }
-
SUPER(AIController, tick, dt);
}
More information about the Orxonox-commit
mailing list