Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 1, 2015, 10:03:10 AM (9 years ago)
Author:
gania
Message:

decided to get rid of action timer and call action in tick instead: action is being called once in 2 sec in a tick, 2 sec were split in 4 * 0.25 sec, with 0.25 sec gap for each member of division to call its action, resulted in significant speed up.

Location:
code/branches/campaignHS15
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/data/levels/AITest.oxw

    r10906 r10909  
    157157<!-- HERE STARTS DEMO FOR FIGHTING -->
    158158   
    159 <!--
     159
    160160    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
    161161      <templates>
     
    297297        </WingmanController>
    298298      </controller>
    299     </SpaceShip> -->
     299    </SpaceShip>
    300300    <SpaceShip position="1000, -2400, 1000" lookat="0,0,0" team=1 name="d2s1w2">
    301301      <templates>
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc

    r10906 r10909  
    9191        if (maneuverCounter_ > 6.0f)
    9292            maneuverCounter_ = 0;
     93        this->timeOffset_ += dt;
     94        if (this->timeOffset_ >= 2.0f)
     95            this->timeOffset_ = 0.0f;
    9396        if (timeout_ <= 0)
    9497            this->bFiredRocket_ = false;
     
    102105            this->lookAtTarget(dt);
    103106        }
     107
     108
    104109        if (this->bShooting_)
    105110        {
     
    117122        if (this->bFirstTick_)
    118123        {   
     124            this->timeOffset_ = 0.0f;
     125            this->bActionCalled_ = false;
    119126            setSpawners();
    120127            // orxout(internal_error) << "health spawners size = " << this->healthSpawners_.size() <<
     
    123130            this->bFirstTick_ = false;
    124131        }
    125         if (this->hasTarget())
    126         {
     132
     133        //maneuver every 0.25 sec ->
     134        float currentPeriodTime = this->timeOffset_ - static_cast<int>(this->timeOffset_);
     135        if (this->hasTarget() && ((currentPeriodTime >= 0.25f && currentPeriodTime <= 0.5f) || (currentPeriodTime >= 0.75 && currentPeriodTime <= 0.999f)) && !this->bManeuverCalled_)
     136        {
     137            this->bManeuverCalled_ = true;
    127138            this->maneuver();
    128             if (static_cast<int>(this->maneuverCounter_*100) % 3 == 0)
    129                 this->bShooting_ = this->canFire();
    130         }
     139            this->bShooting_ = this->canFire();
     140        }
     141        if ((currentPeriodTime >= 0.0f && currentPeriodTime <= 0.25f) || (currentPeriodTime >= 0.5f && currentPeriodTime <= 0.75f))
     142            this->bManeuverCalled_ = false;
    131143        SUPER(ActionpointController, tick, dt);
    132144    }
     
    137149        if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
    138150            return;
    139             this->startAttackingEnemiesThatAreClose();
     151        this->startAttackingEnemiesThatAreClose();
    140152
    141153        this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
     
    546558            return;
    547559        } 
    548         if (this->actionCounter_ % 3 == 0)
    549             this->setTargetOrientation(this->getProtect()->getWorldOrientation());
     560        this->setTargetOrientation(this->getProtect()->getWorldOrientation());
    550561    }
    551562    void ActionpointController::nextActionpoint()
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h

    r10898 r10909  
    236236                std::multimap <int, std::pair<PickupSpawner*, bool> > speedSpawners_;
    237237
     238                float timeOffset_;
     239                bool bActionCalled_;
     240                bool bManeuverCalled_;
     241
    238242        private:
    239243           
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10886 r10909  
    4343        this->myFollower_ = 0;
    4444        this->myWingman_ = 0;
    45         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
     45        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
    4646    }
    4747
     
    6868            return;   
    6969        SUPER(DivisionController, tick, dt);
     70        if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.5f && !this->bActionCalled_)
     71        {
     72            this->action();
     73            this->bActionCalled_ = true;
     74        }
     75        if (this->timeOffset_ > 1.0f)
     76        {
     77            this->bActionCalled_ = false;
     78        }
     79
     80       
    7081    }
    7182    void DivisionController::action()
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10906 r10909  
    4444        this->setFormationMode(FormationMode::FINGER4);
    4545
    46         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
     46        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
    4747        this->myWingman_ = 0;
    4848        this->myDivisionLeader_ = 0;
     
    7474   
    7575        SUPER(SectionController, tick, dt);
     76        if (this->timeOffset_ >= 0.5f && this->timeOffset_ <= 1.0f && !this->bActionCalled_)
     77        {
     78            this->action();
     79            this->bActionCalled_ = true;
     80        }
     81        if (this->timeOffset_ > 1.5f)
     82        {
     83            this->bActionCalled_ = false;
     84        }
    7685    }
    7786
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10906 r10909  
    3939    {
    4040        RegisterObject(WingmanController);
    41         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
     41        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
    4242        this->myLeader_ = 0;
    4343        this->bFirstAction_ = true;
     
    6868       
    6969        SUPER(WingmanController, tick, dt);
     70        if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.5f && !this->bActionCalled_)
     71        {
     72            this->action();
     73            this->bActionCalled_ = true;
     74        }
     75        if (this->timeOffset_ <= 0.5f)
     76        {
     77            this->bActionCalled_ = false;
     78        }
    7079    }
    7180   
     
    229238            if (closestLeader->setWingman(orxonox_cast<ActionpointController*>(this)))
    230239            {
     240                if (closestLeader->getIdentifier()->getName() == "SectionController")
     241                {
     242                    this->actionTime_ = 1.0f;
     243                }
     244                else
     245                {
     246                    this->actionTime_ = 1.5f;
     247                }
    231248                return closestLeader;
    232249            }
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h

    r10886 r10909  
    7070                Timer actionTimer_; //<! Regularly calls action().
    7171                bool bFirstAction_;
    72 
     72                float actionTime_;
    7373    };
    7474}
Note: See TracChangeset for help on using the changeset viewer.