Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2015, 6:46:20 PM (8 years ago)
Author:
gania
Message:

almost all works now, check AITest.oxw

File:
1 edited

Legend:

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

    r10856 r10859  
    6363    CommonController::CommonController( Context* context ): Controller( context )
    6464    {
    65         this->squaredaccuracy_ = 10000;
     65        this->squaredaccuracy_ = 2500;
    6666        this->bFirstTick_ = true;
    6767        this->tolerance_ = 50;
     
    7171        this->bInLoop_ = false;
    7272        this->bLoop_ = false;
     73        this->bEndLoop_ = false;
     74        this->parsedActionpoints_.clear();
    7375        RegisterObject( CommonController );
     76
    7477    }
    7578    CommonController::~CommonController()
    7679    {
    77        
    7880    }
    7981    void CommonController::tick(float dt)
     
    161163        Vector3 position;
    162164        std::string targetName;
    163         bool inLoop;
     165        bool inLoop = false;
    164166        Point p;
    165167        if (static_cast<Actionpoint*> (actionpoint))
     
    170172            position = ap->getWorldPosition();
    171173
    172             if (!this->bInLoop_ && ap->getStartLoop())
     174            if (this->bEndLoop_)
     175            {
     176                this->bInLoop_ = false;
     177            }
     178            if (!this->bInLoop_ && ap->getLoopStart())
    173179            {
    174180                this->bInLoop_ = true;
    175181            }
    176             if (this->bInLoop_ && ap->getEndLoop())
    177             {
    178                 this->bInLoop_ = false;
     182            if (this->bInLoop_ && ap->getLoopEnd())
     183            {
     184                this->bEndLoop_ = true;
    179185            }
    180186            inLoop = this->bInLoop_;
     
    197203                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
    198204            p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
    199             parsedActionpoints_.push_back(p);
    200205        }
    201206        else
     
    519524        while( diff>math::twoPi )diff-=math::twoPi;
    520525        while( diff<-math::twoPi )diff+=math::twoPi;
    521         this->getControllableEntity() ->rotateRoll( diff*ROTATEFACTOR * dt );
     526        this->getControllableEntity() ->rotateRoll( diff*0.2f*ROTATEFACTOR * dt );
    522527    }
    523528    void CommonController::copyTargetOrientation( float dt )
     
    975980    void CommonController::nextActionpoint()
    976981    {
     982        if (!this || !this->getControllableEntity())
     983            return;
    977984        if (this->bLoop_)
    978985        {
     
    10191026    void CommonController::action()
    10201027    {
     1028        if (!this || !this->getControllableEntity())
     1029            return;
     1030        orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
    10211031        this->startAttackingEnemiesThatAreClose();
    10221032        //No action -> pop one from stack
     
    11261136      this->bLoop_ = b;
    11271137      this->setAction (Action::NONE);
    1128       this->setTarget(0);
    1129       this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
     1138      // this->setTarget(0);
     1139      // this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
    11301140      orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
    11311141    }
Note: See TracChangeset for help on using the changeset viewer.