Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8736


Ignore:
Timestamp:
Jul 7, 2011, 7:17:39 PM (13 years ago)
Author:
jo
Message:

Bots use boost now.

Location:
code/branches/ai2/src/orxonox/controllers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai2/src/orxonox/controllers/AIController.cc

    r8735 r8736  
    211211            this->resetDeathFlag();
    212212        }
     213        this->boostControl();//TEST
    213214        float random;
    214215        float maxrand = 100.0f / ACTION_INTERVAL;
     
    281282                if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over.
    282283                {
    283                     this->follow(); //TODO: CHECK: does follow make the bot crash into the target_ ?
     284                    this->follow();
    284285                    this->timeout_ -= dt;
    285286                    if((timeout_< 0)||(!target_))//Check if the timeout is over or target died.
  • code/branches/ai2/src/orxonox/controllers/ArtificialController.cc

    r8735 r8736  
    3939#include "worldentities/pawns/Pawn.h"
    4040#include "worldentities/pawns/TeamBaseMatchBase.h"
     41#include "worldentities/pawns/SpaceShip.h"
    4142#include "gametypes/TeamDeathmatch.h"
    4243#include "gametypes/Dynamicmatch.h"
     
    4748#include "weaponsystem/WeaponPack.h"
    4849#include "weaponsystem/Weapon.h"
     50
    4951
    5052namespace orxonox
     
    10381040        {
    10391041            this->setupWeapons();
    1040             if(numberOfWeapons>0)
    1041                 bSetupWorked=true;
    1042         }
    1043         else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f))
    1044         {
    1045             if (this->isCloseAtTarget(130) &&weapons[1] )
     1042            if(numberOfWeapons > 0)
     1043                bSetupWorked = true;
     1044        }
     1045        else if(this->getControllableEntity() && (numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f))
     1046        {
     1047            float random = rnd(1);//
     1048            if (this->isCloseAtTarget(130) && weapons[1] )
    10461049            {//LENSFLARE: short range weapon     
    10471050                this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target
    10481051            }
    1049             else if(weapons[3]&& this->isCloseAtTarget(400) /*&&projectiles[3]*/ )
     1052            else if(weapons[3] && this->isCloseAtTarget(400) && (projectiles[3] > 0) && (random < this->botlevel_) )
    10501053            {//ROCKET: mid range weapon
    1051                 //TODO: How many rockets are available?
    1052                 this->mode_ = ROCKET;//Vector-implementation: mode_.push_back(ROCKET);
    1053                 this->getControllableEntity()->fire(3);//launch rocket
    1054                 if(this->getControllableEntity()&&this->target_)//after fire(3) getControllableEntity() refers to the rocket!
     1054                this->mode_ = ROCKET; //Vector-implementation: mode_.push_back(ROCKET);
     1055                this->getControllableEntity()->fire(3); //launch rocket
     1056                if(this->getControllableEntity() && this->target_) //after fire(3) is called, getControllableEntity() refers to the rocket!
    10551057                {
    10561058                    float speed = this->getControllableEntity()->getVelocity().length() - target_->getVelocity().length();
    10571059                    if(!speed) speed = 0.1f;
    10581060                    float distance = target_->getPosition().length() - this->getControllableEntity()->getPosition().length();
    1059                     this->timeout_= distance/speed*sgn(speed*distance) + 1.8f;//predicted time of target hit (+ tolerance)
     1061                    this->timeout_= distance/speed*sgn(speed*distance) + 1.8f; //predicted time of target hit (+ tolerance)
    10601062                }
    10611063                else
    1062                     this->timeout_ = 4.0f;//TODO: find better default value
    1063                
    1064                 this->projectiles[3]-=1;//decrease ammo !!
     1064                    this->timeout_ = 4.0f; //TODO: find better default value
     1065                this->projectiles[3] -= 1; //decrease ammo
    10651066            }
    10661067            else if (weapons[0])//LASER: default weapon
     
    10791080            if(pawn)
    10801081            {
    1081                 for(unsigned int i=0; i<WeaponSystem::MAX_WEAPON_MODES; i++)
     1082                for(unsigned int i=0; i < WeaponSystem::MAX_WEAPON_MODES; i++)
    10821083                {
    1083                     //const std::string wpn = getWeaponname(i, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info.
    1084                     /*if(wpn=="")
     1084                    const std::string wpn = getWeaponname(i, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info.
     1085                    /*if(wpn=="") //future, more generic implementation; until now, only LaserMunition works. Is this a bug??
    10851086                        weapons[i]=false;
    10861087                    else if(wpn=="LaserMunition")//other munitiontypes are not defined yet :-(
     
    10971098                    if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment!
    10981099                    {
    1099                         weapons[i]=true;
    1100                         projectiles[i]=1;//TODO: how to express infinite ammo? how to get data?? getWeaponmode(i)->getMunition()->getNumMunition(WeaponMode* user)
     1100                        weapons[i] = true;
     1101                        projectiles[i] = 10; //TODO: how to get data?? getWeaponmode(i)->getMunition()->getNumMunition(WeaponMode* user)
    11011102                          numberOfWeapons++;
    11021103                    }
    11031104                    else
    1104                         weapons[i]=-false;
     1105                        weapons[i] = false;
    11051106                }
    11061107                 //pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
     
    11431144    }
    11441145   
     1146    void ArtificialController::boostControl()
     1147    {
     1148        SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
     1149        if(ship == NULL) return;
     1150        if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() )//upper limit ->boost
     1151            this->getControllableEntity()->boost(true);
     1152        else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower())//lower limit ->do not boost
     1153            this->getControllableEntity()->boost(false);
     1154    }
     1155
    11451156}
  • code/branches/ai2/src/orxonox/controllers/ArtificialController.h

    r8735 r8736  
    142142
    143143            static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack
     144            void boostControl();
    144145
    145146            bool bHasTargetPosition_;
Note: See TracChangeset for help on using the changeset viewer.