Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2015, 12:07:22 PM (8 years ago)
Author:
gania
Message:

Fixed some bugs, only DivisionController works for now

File:
1 edited

Legend:

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

    r10851 r10854  
    4848    WingmanController::~WingmanController()
    4949    {
    50 
     50        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
     51        {
     52            if(this->actionpoints_[i])
     53                this->actionpoints_[i]->destroy();
     54        }
     55        this->parsedActionpoints_.clear();
     56        this->actionpoints_.clear();
    5157    }
    5258 
     
    8692        if (!this->myLeader_)
    8793        {
    88             bool b = this->startAttackingEnemiesThatAreClose();
     94           CommonController::action();
     95        }
     96        else if (this->myLeader_)
     97        {
    8998
    90             if (this->action_ == Action::NONE)
    91             {
    92                 this->executeActionpoint();
    93             }
    94             if (this->action_ == Action::FIGHT || this->action_ == Action::FIGHTALL)
    95             {
    96                 if (!this->hasTarget())
    97                 {
    98                     //----find a target----
    99                     ControllableEntity* newTarget = this->closestTarget();
    100                     if (this->action_ == Action::FIGHT)
    101                     {
    102                         if (newTarget &&
    103                                 CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
    104                         {
    105                             this->setAction (Action::FIGHT, newTarget);
    106                         }
    107                         else
    108                         {
    109                             this->nextActionpoint();
    110                             return;
    111                         }
    112                     }
    113                     else if (this->action_ == Action::FIGHTALL)
    114                     {
    115                         if (newTarget && newTarget->getController())
    116                         {
    117                             this->setAction (Action::FIGHTALL, newTarget);
    118                         }
    119                         else
    120                         {
    121                             this->nextActionpoint();
    122                             return;
    123                         }
    124                     }
    125 
    126                 }
    127                 else if (this->hasTarget())
    128                 {
    129                     //----fly in formation if far enough----
    130                     Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
    131                        
    132                     if (diffVector.length() > this->attackRange_)
    133                     {
    134                         if (this->action_ == Action::FIGHT)
    135                         {
    136                             this->nextActionpoint();
    137                             return;
    138                         }
    139                     }
    140                 }
    141             }
    142             else if (this->action_ == Action::FLY)
    143             {
    144                 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
    145                 {
    146                     this->nextActionpoint();
    147                     return;
    148                 }
    149             }
    150             else if (this->action_ == Action::PROTECT)
    151             {
    152                 if (!this->getProtect())
    153                 {
    154                     this->nextActionpoint();
    155                     return;
    156                 }
    157 
    158                 Vector3* targetRelativePosition;
    159                    
    160                 targetRelativePosition = new Vector3 (0, 300, 300); 
    161      
    162                 Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) +
    163                     (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
    164                 this->setTargetPosition(targetAbsolutePosition);
    165                
    166 
    167             }
    168             else if (this->action_ == Action::ATTACK)
    169             {   
    170                 if (!this->hasTarget())
    171                 {
    172                     this->nextActionpoint();
    173                     return;
    174                 }
    175                        
    176             }
    177             if (this->hasTarget())
    178             {
    179                 //----choose where to go----
    180                 this->maneuver();
    181                 //----fire if you can----
    182                 this->bShooting_ = this->canFire();               
    183             }
    18499        }
    185         else
    186         {
    187             //----action was set to fight----
    188             if (this->action_ == Action::FIGHT)
    189             {
    190                 //----If no leader found, attack someone----
    191                 if (!this->hasTarget())
    192                 {
    193                     this->setClosestTarget();
    194                 }
    195                 if (this->hasTarget())
    196                 {
    197                     //----choose where to go----
    198                     this->maneuver();
    199                     //----fire if you can----
    200                     this->bShooting_ = this->canFire();               
    201                 }
    202             }
    203             //----action was set to fly, leader handles the logic----
    204             else if (this->action_ == Action::FLY)
    205             {
    206 
    207             }
    208         }
    209         if (this->bFirstAction_ && this->myLeader_)
    210         {
    211             this->parsedActionpoints_ = this->myLeader_->parsedActionpoints_;
    212             this->bFirstAction_ = false;
    213         }
     100       
    214101    }
    215102     
Note: See TracChangeset for help on using the changeset viewer.