Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 11, 2015, 3:16:48 PM (8 years ago)
Author:
gania
Message:

a little clean up

File:
1 edited

Legend:

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

    r10958 r10968  
    5353        this->bDefaultPatrol_ = true;
    5454        this->bDefaultFightAll_ = true;
    55         this->stop_ = false;
    5655        RegisterObject(ActionpointController);
    5756
     
    7574    void ActionpointController::tick(float dt)
    7675    {
    77         if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_)
     76        if (!this || !this->getControllableEntity() || !this->isActive())
    7877            return;
    7978
     
    733732        if (!this || !this->getControllableEntity())
    734733            return;
    735 
    736         //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
    737         {
    738             if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
    739             {
    740                 if (!this || !this->getControllableEntity())
    741                     return;
    742                 Pawn* newTarget = this->closestTarget();
    743                 if ( newTarget &&
    744                     CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
    745                         <= this->attackRange_ )
    746                 {
    747                     if (!this || !this->getControllableEntity())
    748                         return;
    749                     this->setTarget(newTarget);
    750                     if (this->bLoop_ && !this->bPatrolling_)
    751                     {
    752                         Point p = { Action::FIGHT, "", Vector3::ZERO, true };
    753                         this->loopActionpoints_.push_back(p);
    754                     }
    755                     else if (!this->bPatrolling_)
    756                     {
    757                         //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
    758                         Point p = { Action::FIGHT, "", Vector3::ZERO, false };
    759                         this->parsedActionpoints_.push_back(p);
    760                     }
    761                     this->bPatrolling_ = true;
    762                     this->executeActionpoint();
    763                 }
     734       
     735        if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
     736        {
     737            if (!this || !this->getControllableEntity())
     738                return;
     739            Pawn* newTarget = this->closestTarget();
     740            if ( newTarget &&
     741                CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
     742                    <= this->attackRange_ )
     743            {
     744                if (!this || !this->getControllableEntity())
     745                    return;
     746                this->setTarget(newTarget);
     747                if (this->bLoop_ && !this->bPatrolling_)
     748                {
     749                    Point p = { Action::FIGHT, "", Vector3::ZERO, true };
     750                    this->loopActionpoints_.push_back(p);
     751                }
     752                else if (!this->bPatrolling_)
     753                {
     754                    Point p = { Action::FIGHT, "", Vector3::ZERO, false };
     755                    this->parsedActionpoints_.push_back(p);
     756                }
     757                this->bPatrolling_ = true;
     758                this->executeActionpoint();
    764759            }
    765760        }
Note: See TracChangeset for help on using the changeset viewer.