Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2015, 10:31:23 AM (8 years ago)
Author:
gania
Message:

little fix

File:
1 edited

Legend:

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

    r10912 r10915  
    4040    ActionpointController::ActionpointController(Context* context) : FightingController(context)
    4141    {
     42        this->bPatrolling_ = false;
     43
    4244        this->actionCounter_ = 0;
    4345        this->bInLoop_ = false;
     
    100102    void ActionpointController::tick(float dt)
    101103    {
     104        if (!this->getControllableEntity())
     105            return;
    102106        if (stop_)
    103107            return;
     
    109113        {
    110114            this->timeDodged_ += dt;
    111             if (this->timeDodged_ > 2.0f)
     115            if (this->timeDodged_ > 4.0f)
    112116            {
    113117                this->bStartedDodging_ = false;
     
    119123            maneuverCounter_ = 0;
    120124        this->timeOffset_ += dt;
    121         if (this->timeOffset_ >= 2.0f)
     125        if (this->timeOffset_ >= 2.4f)
    122126            this->timeOffset_ = 0.0f;
    123127        if (timeout_ <= 0)
     
    133137        }
    134138
    135 
     139        if (!this->getControllableEntity())
     140            return;
    136141        if (this->bShooting_)
    137142        {
     
    157162            this->bFirstTick_ = false;
    158163        }
    159 
     164        if (!this->getControllableEntity())
     165            return;
    160166        //maneuver every 0.25 sec ->
    161         float currentPeriodTime = this->timeOffset_ - static_cast<int>(this->timeOffset_);
    162         if (this->hasTarget() && ((currentPeriodTime >= 0.25f && currentPeriodTime <= 0.5f) || (currentPeriodTime >= 0.75 && currentPeriodTime <= 0.999f)) && !this->bManeuverCalled_)
     167        if (this->hasTarget() &&
     168            ((this->timeOffset_ >= 0.4f && this->timeOffset_ < 0.8f) ||
     169             (this->timeOffset_ >= 1.2f && this->timeOffset_ < 1.6f) ||
     170             (this->timeOffset_ >= 1.8f && this->timeOffset_ < 2.0f) ||
     171             (this->timeOffset_ >= 2.2f && this->timeOffset_ < 2.4f)) && !this->bManeuverCalled_)
    163172        {
    164173            this->bManeuverCalled_ = true;
     
    166175            this->bShooting_ = this->canFire();
    167176        }
    168         if ((currentPeriodTime >= 0.0f && currentPeriodTime <= 0.25f) || (currentPeriodTime >= 0.5f && currentPeriodTime <= 0.75f))
     177        if ((this->timeOffset_ >= 0.0f && this->timeOffset_ < 0.4f) ||
     178             (this->timeOffset_ >= 0.8f && this->timeOffset_ < 1.2f) ||
     179             (this->timeOffset_ >= 1.6f && this->timeOffset_ < 1.8f) ||
     180             (this->timeOffset_ >= 2.0f && this->timeOffset_ < 2.2f))
    169181            this->bManeuverCalled_ = false;
    170182        SUPER(ActionpointController, tick, dt);
     
    183195            this->startAttackingEnemiesThatAreClose();
    184196        }
    185 
    186197        this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
    187198        this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
     
    217228                {
    218229                    this->setAction (Action::FIGHTALL, newTarget);
    219                     this->action();
     230                    //this->action();
    220231                }
    221232                else
    222233                {
    223234                    this->nextActionpoint();
    224                     if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
    225                     {
    226                         this->action();
    227                     }
    228                     else
    229                     {
    230                     }     
     235                    this->executeActionpoint();
     236   
    231237                }
    232238            }
     
    244250                {
    245251                    this->setAction (Action::FIGHT, newTarget);
    246                     this->action();
     252                    //this->action();
    247253                }
    248254                else
    249255                {
    250256                    this->nextActionpoint();
    251                     this->action();
     257                    this->executeActionpoint();
    252258                }
    253259            }
     
    269275                    {
    270276                        this->nextActionpoint();
    271                         this->action();
     277                        this->executeActionpoint();
    272278                    }
    273279                }
     
    279285            {
    280286                this->nextActionpoint();   
    281                 this->action();
     287                this->executeActionpoint();
    282288            }
    283289        }
     
    287293            {
    288294                this->nextActionpoint();
    289                 this->action();
     295                this->executeActionpoint();
    290296            }
    291297            this->stayNearProtect();
     
    297303            {
    298304                this->nextActionpoint();
    299                 this->action();
     305                this->executeActionpoint();
    300306            }
    301307        }
     
    599605        if (this->bLoop_)
    600606        {
    601             if (!this->loopActionpoints_.empty())
     607            if (this->bPatrolling_)
     608            {
     609                this->loopActionpoints_.pop_back();
     610                this->bPatrolling_ = false;
     611            }
     612            else if (!this->loopActionpoints_.empty())
    602613            {
    603614                this->moveBackToTop();
     
    689700                        <= this->attackRange_ )
    690701                {
    691                     if (this->bLoop_)
     702                    this->setTarget(newTarget);
     703                    if (this->bLoop_ && !this->bPatrolling_)
    692704                    {
    693                         Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, true };
     705                        Point p = { Action::FIGHT, "", Vector3::ZERO, true };
    694706                        this->loopActionpoints_.push_back(p);
    695707                    }
    696                     else
     708                    else if (!this->bPatrolling_)
    697709                    {
    698710                        //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
    699                         Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
     711                        Point p = { Action::FIGHT, "", Vector3::ZERO, false };
    700712                        this->parsedActionpoints_.push_back(p);
    701713                    }
     714                    this->bPatrolling_ = true;
    702715                    this->executeActionpoint();
    703716                }
Note: See TracChangeset for help on using the changeset viewer.