Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2015, 11:07:34 PM (8 years ago)
Author:
gania
Message:

fixed pointers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc

    r10722 r10725  
    4040        RegisterObject(WingmanController);
    4141        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
     42        this->myLeader_ = 0;
     43        this->desiredRelativePosition_ = 0;
    4244    }
    4345
    4446    WingmanController::~WingmanController()
    4547    {
    46         if (this->myLeader_)
    47             this->myLeader_->myWingman_ = 0;
     48
    4849    }
    4950
     
    6970                continue;
    7071
    71 
    72 
    73          
    74 
    7572            float distance = (it->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length();
    7673            if (distance < minDistance && !(it->hasWingman()))
     
    7976                minDistance = distance;
    8077            }
    81             /*// is pawn in range?
    82             if (distance < RADIUS_TO_SEARCH_FOR_LEADER)
    83             {
    84 
    85                 if (it->setWingman(this))
    86                     return *it;
    87             }*/
     78           
    8879        }
    8980        if (closestLeader)
     
    110101        else
    111102        {
    112 
    113             //orxout(internal_error) << "already have a Leader" << endl;
    114103
    115104        }
     
    155144            }*/
    156145
    157       /*  void FormationController::setDesiredPositionOfSlaves()
     146     
     147    /*void WingmanController::keepSectionTick()
    158148    {
    159         if (this->state_ != MASTER)
    160             return;
    161         switch (this->formationMode_){
    162             case ATTACK:
    163             {
    164                 float i = 0;
    165                 for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    166                 {
    167                     (*it)->desiredRelativePosition_ = new Vector3 ((i-slaves_.size()/2)*200, 0, 0);
    168                     i++;
    169                 }
    170                 break;
    171             }
    172             case NORMAL:
    173             {
    174                 break;
    175             }
    176             case DEFEND:
    177             {
    178                 break;
    179             }
     149        if (this->myLeader_ && this->myLeader_->getControllableEntity())
     150                            //orxout(internal_error) << "MOVING" << endl;
     151
     152        if (this->myLeader_ && this->myLeader_->getControllableEntity() && desiredRelativePosition_)
     153        {
     154            Vector3 desiredAbsolutePosition = ((this->myLeader_->getControllableEntity()->getWorldPosition()) +
     155                (this->myLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
     156            this->moveToPosition (desiredAbsolutePosition);
    180157        }
    181        
    182158    }*/
    183159    void WingmanController::tick(float dt)
    184160    {   
    185         //-------------------------------------------------------
     161       /* //-------------------------------------------------------
    186162           
    187         /*
     163       
    188164        if (!this->isActive())
    189165            return;
    190166        //--------------------------Stay in formation--------------------------
    191         if (bFollowLeader_)
     167        this->keepSectionTick();*/
     168           
     169       
     170        //--------------------------Attack same target as the Leader--------------------------
     171
     172        /*if (this->target_)
    192173        {
    193             this->keepSectionTick();
    194            
    195             keepSectionTick(){
    196                 if (this->sectionLeader_ && this->sectionLeader_->getControllableEntity() && desiredRelativePosition_){
    197                     Vector3 desiredAbsolutePosition = ((this->sectionLeader_->getControllableEntity()->getWorldPosition()) +
    198                         (this->sectionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
    199                     this->moveToPosition (desiredAbsolutePosition);
    200                 }
    201             }
    202            
    203            
    204             //--------------------------Attack same target as the Leader--------------------------
    205 
    206             if (this->target_)
    207             {
    208                 this->aimAtTarget();
    209                 this->doFire();
    210             }
     174            this->aimAtTarget();
     175            this->doFire();
    211176        }
    212         */
    213          //orxout(internal_error) << "I am " << this << endl;
     177*/
     178       
     179        //orxout(internal_error) << "I am " << this << endl;
    214180
    215181       
Note: See TracChangeset for help on using the changeset viewer.