Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 22, 2015, 5:06:38 PM (8 years ago)
Author:
gania
Message:

some comments added

File:
1 edited

Legend:

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

    r10805 r10826  
    3535    RegisterClass(DivisionController);
    3636
     37    //Leaders share the fact that they have Wingmans
    3738    DivisionController::DivisionController(Context* context) : LeaderController(context)
    3839    {
     
    5354    }
    5455
     56    void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     57    {
     58        SUPER(DivisionController, XMLPort, xmlelement, mode);
     59
     60        //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
     61    }
     62
    5563   
    5664    void DivisionController::tick(float dt)
     
    7684    void DivisionController::action()
    7785    {
    78         if (!this->target_)
     86        //----find a target----
     87        if ( !this->hasTarget() )
    7988        {
    8089            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    8190            {
    82                 if (this->getControllableEntity()->getTeam() == static_cast<ControllableEntity*>(*itP)->getTeam())
     91                if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
    8392                    continue;           
    8493
    8594               
    86                 if (static_cast<ControllableEntity*>(*itP) != (this)->getControllableEntity() && !(this)->hasTarget()
    87                     && ((*itP)->getWorldPosition() - (this)->getControllableEntity()->getWorldPosition()).length() < 10000)
     95                if (static_cast<ControllableEntity*>(*itP) != (this)->getControllableEntity()
     96                    && CommonController::distance (*itP, this->getControllableEntity()) < 10000)
    8897                {
    8998                    (this)->setAction(Action::FIGHT, *itP);
     
    94103        if (this->action_ == Action::FIGHT)
    95104        {
     105            //----choose where to go----
    96106            this->maneuver();
     107            //----fire if you can----
    97108            this->bShooting_ = this->canFire();
     109
    98110            if (this->target_)
    99111            {
    100112                if (this->myWingman_)
    101113                {
     114                    //----wingmans shall support the fire of their leaders----
    102115                    this->myWingman_->setAction (Action::FIGHT, this->target_);                   
    103116                }
    104117               
     118                //----fly in formation if far enough----
    105119                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
    106120                if (diffVector.length() > 3000)
     
    141155                break;
    142156            }
    143             case FormationMode::VEE:
    144             {
    145                 break;
    146             }
     157         
    147158            case FormationMode::DIAMOND:
    148159            {
     
    177188                break;
    178189            }
    179             case FormationMode::VEE:
    180             {
    181                 break;
    182             }
     190           
    183191            case FormationMode::DIAMOND:
    184192            {
     
    239247
    240248
    241     void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    242     {
    243         SUPER(DivisionController, XMLPort, xmlelement, mode);
    244 
    245         //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
    246     }
    247 
    248249   
    249250   
Note: See TracChangeset for help on using the changeset viewer.