[Orxonox-commit 4059] r8730 - code/branches/ai2/src/orxonox/controllers
jo at orxonox.net
jo at orxonox.net
Tue Jul 5 22:16:48 CEST 2011
Author: jo
Date: 2011-07-05 22:16:47 +0200 (Tue, 05 Jul 2011)
New Revision: 8730
Modified:
code/branches/ai2/src/orxonox/controllers/AIController.cc
Log:
Going back one step (version without hud bug). Bots have better combat strength but do not use all weapons available.
Modified: code/branches/ai2/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/ai2/src/orxonox/controllers/AIController.cc 2011-07-04 00:47:44 UTC (rev 8729)
+++ code/branches/ai2/src/orxonox/controllers/AIController.cc 2011-07-05 20:16:47 UTC (rev 8730)
@@ -158,12 +158,12 @@
// search enemy
random = rnd(maxrand);
- if (random < (botlevel_)*25 && (!this->target_))
+ if (random < 15 && (!this->target_))
this->searchNewTarget();
// forget enemy
random = rnd(maxrand);
- if (random < (1-botlevel_)*6 && (this->target_))
+ if (random < 5 && (this->target_))
this->forgetTarget();
// next enemy
@@ -184,15 +184,15 @@
// shoot
random = rnd(maxrand);
- if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_))
+ if (!(this->passive_) && random < 9 && (this->target_ && !this->bShooting_))
{
- this->bShooting_ = true;
- this->forceFreeSlaves();
+ this->bShooting_ = true;
+ this->forceFreeSlaves();
}
// stop shooting
random = rnd(maxrand);
- if (random < ( (1- botlevel_)*25 ) && (this->bShooting_))
+ if (random < 25 && (this->bShooting_))
this->bShooting_ = false;
}
@@ -202,15 +202,12 @@
void AIController::tick(float dt)
{
- float random;
- float maxrand = 100.0f / ACTION_INTERVAL;
-
if (!this->isActive())
return;
- //Vector-implementation: if(target_.size() == 0) target[0] = DEFAULT;
- if(this->mode_ == DEFAULT)
- {//Vector-implementation: mode_.back() == DEFAULT;
+ float random;
+ float maxrand = 100.0f / ACTION_INTERVAL;
+
if (this->state_ == MASTER)
{
if (this->specificMasterAction_ == NONE)
@@ -225,7 +222,8 @@
if (this->bHasTargetPosition_)
this->moveToTargetPosition();
- this->doFire();
+ if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
+ this->getControllableEntity()->fire(0);
}
if (this->specificMasterAction_ == TURN180)
@@ -257,32 +255,10 @@
if (this->bHasTargetPosition_)
this->moveToTargetPosition();
- this->doFire();
+ if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
+ this->getControllableEntity()->fire(0);
}
- }//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(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
-
SUPER(AIController, tick, dt);
}
More information about the Orxonox-commit
mailing list