Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10915


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

little fix

Location:
code/branches/campaignHS15
Files:
9 edited

Legend:

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

    r10912 r10915  
    3737    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    3838    <TeamSpawnPoint team=0 position="2000, 2000, 2000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     39       
    3940   
    4041<!--     
     
    9192<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS.
    9293P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped -->
    93        <!--
     94      <!--
    9495    <Model mesh="cube.mesh" scale=8 position="0,0,0" />
    9596
  • 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                }
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h

    r10912 r10915  
    8787    {
    8888        public:
     89           
    8990            ActionpointController(Context* context);
    9091            virtual ~ActionpointController();
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10912 r10915  
    6868            return;   
    6969        SUPER(DivisionController, tick, dt);
    70         if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.5f && !this->bActionCalled_)
     70        if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
    7171        {
    7272            this->action();
    7373            this->bActionCalled_ = true;
    7474        }
    75         if (this->timeOffset_ > 1.0f)
     75        if (this->timeOffset_ > 1.6f)
    7676        {
    7777            this->bActionCalled_ = false;
     
    9999            }   
    100100        }
     101
    101102       
    102103    }
     
    154155        return false;
    155156    }
     157
    156158}
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h

    r10886 r10915  
    6767            //----private variables-----
    6868            Timer actionTimer_; //<! Regularly calls action().
     69   
    6970
    7071    };
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10913 r10915  
    7474   
    7575        SUPER(SectionController, tick, dt);
    76         if (this->timeOffset_ >= 0.5f && this->timeOffset_ <= 1.0f && !this->bActionCalled_)
     76        if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
    7777        {
    7878            this->action();
    7979            this->bActionCalled_ = true;
    8080        }
    81         if (this->timeOffset_ > 1.5f)
     81        if (this->timeOffset_ > 2.0f)
    8282        {
    8383            this->bActionCalled_ = false;
    8484        }
     85
    8586    }
    8687
     
    154155            }
    155156        }
     157
    156158        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
    157159    }
     
    294296        return 0;
    295297    }
     298
    296299    bool SectionController::setWingman(ActionpointController* newWingman)
    297300    {
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.h

    r10886 r10915  
    6969                Timer actionTimer_; //<! Regularly calls action().
    7070                bool bFirstAction_;
    71 
    72 
     71               
    7372    };
    7473}
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10909 r10915  
    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         }
     70        if (!this->myLeader_)
     71        {
     72            if (this->actionTime_ == 2.0f)
     73            {
     74                if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
     75                {
     76                    this->action();
     77                    this->bActionCalled_ = true;
     78                }
     79                if (this->timeOffset_ > 1.6f)
     80                {
     81                    this->bActionCalled_ = false;
     82                }
     83            }
     84            else
     85            {
     86                if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
     87                {
     88                    this->action();
     89                    this->bActionCalled_ = true;
     90                }
     91                if (this->timeOffset_ > 2.0f)
     92                {
     93                    this->bActionCalled_ = false;
     94                }
     95            }
     96        }
     97        else
     98        {
     99            if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.4f && !this->bActionCalled_)
     100            {
     101                this->action();
     102                this->bActionCalled_ = true;
     103            }
     104            if (this->timeOffset_ <= 0.5f)
     105            {
     106                this->bActionCalled_ = false;
     107            }
     108        }
     109       
     110
    79111    }
    80112   
     
    240272                if (closestLeader->getIdentifier()->getName() == "SectionController")
    241273                {
    242                     this->actionTime_ = 1.0f;
     274                    this->actionTime_ = 1.6f;
    243275                }
    244276                else
    245277                {
    246                     this->actionTime_ = 1.5f;
     278                    this->actionTime_ = 2.0f;
    247279                }
    248280                return closestLeader;
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h

    r10909 r10915  
    7171                bool bFirstAction_;
    7272                float actionTime_;
     73
     74
    7375    };
    7476}
Note: See TracChangeset for help on using the changeset viewer.