Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 23, 2015, 11:17:22 AM (8 years ago)
Author:
gania
Message:

minor bugfixes and code style improvement

File:
1 edited

Legend:

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

    r10826 r10832  
    8989            this->myDivisionLeader_ = newDivisionLeader;
    9090
    91             if (newDivisionLeader)
    92             {
    93                 //orxout(internal_error) << "new DivisionLeader set" << endl;
    94             }
    95             //----If no leader found, attack someone----
    96             //----TODO: find closest enemy----
    97             else
    98             {
    99                 if ( !this->hasTarget() || this->action_ != Action::FIGHT )
    100                 {
    101                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    102                     {
    103                         if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
    104                             continue;
    105 
    106                         this->setAction(Action::FIGHT, (*itP));
    107                         break;   
    108                     }   
    109                 }
    110                
    111             }
    112 
    11391        }
    11492        //----If have leader----
    11593        else
    11694        {
    117             this->chooseTarget();
    11895        }
    11996
     
    12198        if (this->action_ == Action::FIGHT)
    12299        {
    123             //----choose where to go----
    124             this->maneuver();
    125             //----fire if you can----
    126             this->bShooting_ = this->canFire();
    127 
    128             if (this->target_)
    129             {
    130                 //----wingmans shall support the fire of their leaders----
    131                 if (this->myWingman_)
    132                 {
    133                     this->myWingman_->setAction (Action::FIGHT, this->target_);                   
    134                 }
     100            if (!this->hasTarget())
     101            {
     102                if (this->myDivisionLeader_)
     103                {
     104                    this->chooseTarget();               
     105                }
     106                else
     107                {
     108                    this->setClosestTarget();
     109                }
     110            }
     111            else
     112            {
     113               
    135114                //----fly in formation if far enough----
    136115                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
     
    139118                    this->setTargetPositionOfWingman();
    140119                }   
     120                else
     121                {
     122                    //----wingmans shall support the fire of their leaders----
     123                    if (this->myWingman_)
     124                    {
     125                        this->myWingman_->setAction (Action::FIGHT, this->target_);                   
     126                    }
     127                }
     128            }
     129            if (this->hasTarget())
     130            {
     131                //----choose where to go----
     132                this->maneuver();
     133                //----fire if you can----
     134                this->bShooting_ = this->canFire();               
    141135            }
    142136        }
     
    156150
    157151    }
    158     //PRE: myDivisionLeader_ != 0
     152    //PRE: myDivisionLeader_ != 0 && myDivisionLeader_->action_ == Action::FIGHT
    159153    //POST: this->target_ is set unless division leader doesn't have one
    160154    void SectionController::chooseTarget()
     
    211205
    212206    //----stay in formation----
     207    //gani-TODO: sum targetAbso... and this->predicted position
    213208    void SectionController::setTargetPositionOfWingman()
    214209    {
     
    224219            case FormationMode::FINGER4:
    225220            {
    226                 targetRelativePositionOfWingman = new Vector3 (-400, 0, -200); 
     221                targetRelativePositionOfWingman = new Vector3 (-400, 0, 200); 
    227222                break;
    228223            }
Note: See TracChangeset for help on using the changeset viewer.