Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8991


Ignore:
Timestamp:
Dec 16, 2011, 4:56:15 PM (13 years ago)
Author:
jo
Message:

Works. (Seperate/independent states are used to manage the behaviour).

Location:
code/branches/formation/src/orxonox/controllers
Files:
6 edited

Legend:

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

    r8990 r8991  
    7878        }
    7979
    80         if (this->state_ == SLAVE && this->mode_ == ATTACK) //TODO: add botlevel parameter
     80        if (this->state_ == SLAVE && this->formationMode_ == ATTACK) //TODO: add botlevel parameter
    8181        {
    8282            // search enemy
     
    151151        float maxrand = 100.0f / ACTION_INTERVAL;
    152152        ControllableEntity* controllable = this->getControllableEntity();
    153 
    154         if (controllable && this->mode_ == NORMAL)// bot is ready to move to a target // mode was DEFAULT in original implementation!
     153        //DOES: Either move to the waypoint or search for a Point of interest
     154        if (controllable && this->mode_ == DEFAULT)// bot is ready to move to a target
    155155        {
    156156            if (this->waypoints_.size() > 0 ) //Waypoint functionality.
     
    174174        }
    175175
    176         if (this->mode_ != ROCKET)
     176        if (this->mode_ == DEFAULT)
    177177        {
    178178            if (this->state_ == MASTER)
     
    207207            }
    208208
    209             if (this->state_ == SLAVE && this->mode_!=ATTACK)
     209            if (this->state_ == SLAVE && this->formationMode_ != ATTACK)
    210210            {
    211211                if (this->bHasTargetPosition_)
     
    213213            }
    214214
    215             if (this->state_ == FREE || (this->state_==SLAVE && this->mode_==ATTACK) )
     215            if (this->state_ == FREE || (this->state_==SLAVE && this->formationMode_ == ATTACK) )
    216216            {
    217217                if (this->target_)
  • code/branches/formation/src/orxonox/controllers/ArtificialController.cc

    r8990 r8991  
    5050        this->setAccuracy(5);
    5151        this->defaultWaypoint_ = NULL;
     52        this->mode_ = DEFAULT;//Vector-implementation: mode_.push_back(DEFAULT);
    5253    }
    5354
     
    197198    void ArtificialController::setPreviousMode()
    198199    {
    199         this->mode_ = NORMAL; //Vector-implementation: mode_.pop_back();
     200        this->mode_ = DEFAULT; //Vector-implementation: mode_.pop_back();
    200201    }
    201202
  • code/branches/formation/src/orxonox/controllers/ArtificialController.h

    r8989 r8991  
    7171//************************************************************************* NEW
    7272            float botlevel_; //<! Makes the level of a bot configurable.
     73            enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes
     74            Mode mode_; //TODO: replace single value with stack-like implementation: std::vector<Mode> mode_;
    7375            void setPreviousMode();
    7476
  • code/branches/formation/src/orxonox/controllers/FormationController.cc

    r8990 r8991  
    8181
    8282        this->state_ = FREE;
    83         this->mode_ = NORMAL;
     83        this->formationMode_ = NORMAL;
    8484        this->specificMasterAction_ = NONE;
    8585        this->specificMasterActionHoldCount_  = 0;
     
    652652      @brief Sets the new mode. If master, set it for all slaves.
    653653    */
    654     void FormationController::setMode(Mode val)
    655     {
    656         this->mode_=val;
    657         if (this->state_==MASTER)
     654    void FormationController::setFormationMode(FormationMode val)
     655    {
     656        this->formationMode_ = val;
     657        if (this->state_ == MASTER)
    658658        {
    659659            for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    660660            {
    661                  (*it)->mode_=val;
    662                  if (val==ATTACK)
     661                 (*it)->formationMode_ = val;
     662                 if (val == ATTACK)
    663663                     (*it)->forgetTarget();
    664664            }
  • code/branches/formation/src/orxonox/controllers/FormationController.h

    r8990 r8991  
    8888               Attack-leave formation, attack every target
    8989      */
    90       enum Mode {NORMAL,DEFEND,ATTACK,ROCKET};
     90      enum FormationMode {NORMAL,DEFEND,ATTACK};
    9191     
    9292      /**
    9393        @brief Sets the new mode. If master, set it for all slaves.
    9494      */
    95       void setMode(Mode val);
    96       inline Mode getMode() const
    97            { return this->mode_; }
     95      void setFormationMode(FormationMode val);
     96      inline FormationMode getFormationMode() const
     97           { return this->formationMode_; }
    9898
    9999    protected:
     
    109109      FormationController* myMaster_;
    110110
    111       Mode mode_;
     111      FormationMode formationMode_;
    112112
    113113      enum SpecificMasterAction {NONE, HOLD, SPIN, TURN180, FOLLOW};
  • code/branches/formation/src/orxonox/controllers/HumanController.cc

    r8990 r8991  
    106106        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
    107107        {
    108             if (HumanController::localController_s->mode_!=ATTACK)
     108            if (HumanController::localController_s->formationMode_ != ATTACK)
    109109                HumanController::localController_s->commandSlaves();
    110110        }
     
    177177            HumanController::localController_s->controllableEntity_->fire(firemode);
    178178            //if human fires, set slaves free. See FormationController::forceFreeSlaves()
    179             if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->mode_==NORMAL)
     179            if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->formationMode_ == NORMAL)
    180180            {
    181181                HumanController::localController_s->forceFreeSlaves();
     
    317317        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
    318318        {
    319             switch (HumanController::localController_s->getMode()) {
     319            switch (HumanController::localController_s->getFormationMode()) {
    320320                case NORMAL:
    321                     HumanController::localController_s->setMode(DEFEND);
     321                    HumanController::localController_s->setFormationMode(DEFEND);
    322322                    orxout(message) <<"Mode: DEFEND "<< endl;
    323323                    break;
    324324                case DEFEND:
    325                     HumanController::localController_s->setMode(ATTACK);
     325                    HumanController::localController_s->setFormationMode(ATTACK);
    326326                    orxout(message) <<"Mode: ATTACK "<< endl;
    327327                    break;
    328328                case ATTACK:
    329                     HumanController::localController_s->setMode(NORMAL);
     329                    HumanController::localController_s->setFormationMode(NORMAL);
    330330                    orxout(message) <<"Mode: NORMAL "<< endl;
    331331                    break;
    332                 default: //catch all non-formation related states
    333                     break;
    334332            }
    335333        }
     
    340338    void HumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
    341339    {
    342         if (!this->formationFlight_ || this->state_!=MASTER || this->mode_!=DEFEND) return;
     340        if (!this->formationFlight_ || this->state_!=MASTER || this->formationMode_!=DEFEND) return;
    343341            this->masterAttacked(originator);
    344342    }
Note: See TracChangeset for help on using the changeset viewer.