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/DivisionController.cc

    r10826 r10832  
    8484    void DivisionController::action()
    8585    {
    86         //----find a target----
    87         if ( !this->hasTarget() )
    88         {
    89             for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    90             {
    91                 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
    92                     continue;           
    93 
    94                
    95                 if (static_cast<ControllableEntity*>(*itP) != (this)->getControllableEntity()
    96                     && CommonController::distance (*itP, this->getControllableEntity())  < 10000)
    97                 {
    98                     (this)->setAction(Action::FIGHT, *itP);
    99                 }   
    100             }
    101         }
     86
    10287       
    10388        if (this->action_ == Action::FIGHT)
    10489        {
    105             //----choose where to go----
    106             this->maneuver();
    107             //----fire if you can----
    108             this->bShooting_ = this->canFire();
    109 
    110             if (this->target_)
    111             {
    112                 if (this->myWingman_)
    113                 {
    114                     //----wingmans shall support the fire of their leaders----
    115                     this->myWingman_->setAction (Action::FIGHT, this->target_);                   
    116                 }
    117                
     90            if (!this->hasTarget())
     91            {
     92                //----find a target----
     93                this->setClosestTarget();
     94            }
     95            else
     96            {
    11897                //----fly in formation if far enough----
    11998                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
     
    121100                {
    122101                    this->setTargetPositionOfWingman();
    123                     //this->setTargetPositionOfFollower();                   
    124                 }   
    125             }
     102                    this->setTargetPositionOfFollower();                   
     103                }
     104                else
     105                {
     106                    //----wingmans shall support the fire of their leaders----
     107                    if (this->myWingman_)
     108                    {
     109                        this->myWingman_->setAction (Action::FIGHT, this->target_);     
     110                    }
     111                    if (this->myFollower_)
     112                    {
     113                        this->myFollower_->setAction (Action::FIGHT);                                   
     114                    }
     115
     116                }
     117               
     118            }
     119            if (this->hasTarget())
     120            {
     121                //----choose where to go----
     122                this->maneuver();
     123                //----fire if you can----
     124                this->bShooting_ = this->canFire();               
     125            }
     126
    126127        }
    127128        else if (this->action_ == Action::FLY)
     
    152153            case FormationMode::FINGER4:
    153154            {
    154                 targetRelativePositionOfWingman = new Vector3 (400, 0, -200); 
     155                targetRelativePositionOfWingman = new Vector3 (400, 0, 200); 
    155156                break;
    156157            }
     
    158159            case FormationMode::DIAMOND:
    159160            {
    160                 targetRelativePositionOfWingman = new Vector3 (400, 0, -200);                 
     161                targetRelativePositionOfWingman = new Vector3 (400, 0, 200);                 
    161162                break;
    162163            }
     
    185186            case FormationMode::FINGER4:
    186187            {
    187                 targetRelativePositionOfFollower = new Vector3 (-400, 0, -200);   
     188                targetRelativePositionOfFollower = new Vector3 (-400, 0, 200);   
    188189                break;
    189190            }
     
    191192            case FormationMode::DIAMOND:
    192193            {
    193                 targetRelativePositionOfFollower = new Vector3 (-400, 0, -200);                   
     194                targetRelativePositionOfFollower = new Vector3 (-400, 0, 200);                   
    194195                break;
    195196            }
Note: See TracChangeset for help on using the changeset viewer.