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

    r10826 r10832  
    8585            CommonController* newLeader = findNewLeader();
    8686            this->myLeader_ = newLeader;
    87             if (newLeader)
    88             {
    89                 //orxout(internal_error) << "new Leader set" << endl;
    90             }
    91             //----If no leader found, attack someone----
    92             //----TODO: find closest enemy----
    93             else
    94             {
    95                 if ( !this->hasTarget() || this->action_ != Action::FIGHT )
    96                 {
    97                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    98                     {
    99                         if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
    100                             continue;   
    101                         this->setAction(Action::FIGHT, (*itP));
    102                         break;
    103                     }
    104                 }
    105             }
     87           
    10688        }
    10789        //----If have leader, he will deal with logic----
    10890        else
    10991        {
    110 
     92            this->action_ = this->myLeader_->getAction();
    11193        }
    11294
     
    11597        if (this->action_ == Action::FIGHT)
    11698        {
    117             //----choose where to go----
    118             this->maneuver();
    119             //----fire if you can----
    120             this->bShooting_ = this->canFire();
     99            //----If no leader found, attack someone----
     100            if (!this->hasTarget() && !this->myLeader_)
     101            {
     102                this->setClosestTarget();
     103            }
     104            if (this->hasTarget())
     105            {
     106                //----choose where to go----
     107                this->maneuver();
     108                //----fire if you can----
     109                this->bShooting_ = this->canFire();               
     110            }
    121111        }
    122112        //----action was set to fly, leader handles the logic----
     
    125115
    126116        }
    127         //----TODO: implement protect----
     117        //----gani-TODO: implement protect----
    128118        else if (this->action_ == Action::PROTECT)
    129119        {
Note: See TracChangeset for help on using the changeset viewer.