Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2015, 9:41:38 AM (8 years ago)
Author:
gania
Message:

synchronized AI with a static tick counter

File:
1 edited

Legend:

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

    r10924 r10925  
    110110        }
    111111
     112        if (!this || !this->getControllableEntity())
     113            return;
     114
    112115        if (this->ticks_ == 1)
    113116        {
     
    143146            this->lookAtTarget(dt);
    144147        }
    145         if (this->bShooting_)
    146         {
    147             this->doFire();
    148         }
     148       
    149149
    150150        if (!this || !this->getControllableEntity())
     
    159159        if (timeout_ <= 0)
    160160            this->bFiredRocket_ = false;
    161         if (!this || !this->getControllableEntity())
    162             return;
     161       
    163162
    164163        if (!this || !this->getControllableEntity())
    165164            return;
    166165        if (this->timeout_ > 0 && this->bFiredRocket_)
    167             {
    168                 this->timeout_ -= dt;
    169             }
    170             if (this->bStartedDodging_)
    171             {
    172                 this->timeDodged_ += dt;
    173             }
    174             maneuverCounter_ += dt;
     166        {
     167            this->timeout_ -= dt;
     168        }
     169        if (this->bStartedDodging_)
     170        {
     171            this->timeDodged_ += dt;
     172        }
     173        maneuverCounter_ += dt;
     174
    175175        if (!this || !this->getControllableEntity())
    176176            return;
    177177        //maneuver every 0.25 sec ->
    178178        int step =  4;
    179         if (this->hasTarget() && ActionpointController::sTicks_ % 100 == step * (this->actionpointControllerId_))
    180         {
    181            
    182         }
    183179        if (ActionpointController::sTicks_ % 100 == step * this->actionpointControllerId_ + 1)
    184180        {
     181            //orxout (internal_error) << "Team " << this->getControllableEntity()->getTeam() << (this->hasTarget() ? ", got " : ", don't have") << " target" << endl;
    185182            this->action();
    186183        }
    187         if (!this || !this->getControllableEntity())
    188             return;
    189 
    190        
    191         if (this->hasTarget() &&  ActionpointController::sTicks_ % ActionpointController::nextActionpointControllerId_ == (this->actionpointControllerId_))
     184
     185
     186        if (!this || !this->getControllableEntity())
     187            return;
     188
     189        if (this->hasTarget() &&  ActionpointController::sTicks_ % (ActionpointController::nextActionpointControllerId_ + 1) == (this->actionpointControllerId_))
    192190        {
    193191            if (maneuverCounter_ > 6.0f)
    194                 maneuverCounter_ = 0;
     192                this->maneuverCounter_ = 0;
    195193            if (this->bStartedDodging_ &&  this->timeDodged_ > 4.0f)
    196194            {
     
    199197            }
    200198            if (!this || !this->getControllableEntity())
    201             return;
     199                return;
    202200            this->maneuver();
    203201            if (!this || !this->getControllableEntity())
    204             return;
     202                return;
    205203            this->bShooting_ = this->canFire();
    206         }
    207         if (!this || !this->getControllableEntity())
    208             return;
     204
     205            if (!this || !this->getControllableEntity())
     206                return;
     207
     208            if (this->bShooting_)
     209            {
     210                this->doFire();
     211            }
     212            this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
     213            this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
     214        }
    209215       
    210216
     
    227233            return;
    228234
    229         this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
    230         this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
     235
    231236        if (!this || !this->getControllableEntity())
    232237            return;
     
    514519        }
    515520        this->setAction (p.action);
     521        if (!this || !this->getControllableEntity())
     522            return;
     523
    516524        switch (this->action_)
    517525        {
     
    654662    void ActionpointController::moveBackToTop()
    655663    {
     664        if (!this || !this->getControllableEntity())
     665            return;
     666
    656667        Point temp = loopActionpoints_.back();
    657668        loopActionpoints_.pop_back();
Note: See TracChangeset for help on using the changeset viewer.