Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10935


Ignore:
Timestamp:
Dec 7, 2015, 3:14:40 PM (8 years ago)
Author:
gania
Message:

cleaned source up a bit

Location:
code/branches/campaignHS15/src/orxonox/controllers
Files:
8 edited

Legend:

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

    r10934 r10935  
    5454        this->action_ = Action::NONE;
    5555        this->squaredaccuracy_ = 2500;
    56         this->bFirstTick_ = true;
    5756        this->bStartedDodging_ = false;
    5857        this->bDefaultPatrol_ = true;
     
    6564    {
    6665        SUPER( ActionpointController, XMLPort, xmlelement, mode );
    67         // XMLPortEventSink(ActionpointController, BaseObject, "stop", stop, xmlelement, mode);
    68         // XMLPortEventSink(ActionpointController, BaseObject, "go", stop, xmlelement, mode);
    6966
    7067        XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
     
    7269        XMLPortParam(ActionpointController, "defaultPatrol", setDefaultPatrol, getDefaultPatrol, xmlelement, mode).defaultValues(true);
    7370    }
    74     // void ActionpointController::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    75     // {
    76     //     SUPER(ActionpointController, XMLEventPort, xmlelement, mode);
    77     //     XMLPortEventSink(ActionpointController, BaseObject, "stop", stop, xmlelement, mode);
    78     //     XMLPortEventSink(ActionpointController, BaseObject, "go", stop, xmlelement, mode);
    79 
    80     // }
    81     // bool ActionpointController::stop(bool bTriggered, BaseObject* trigger)
    82     // {
    83     //     this->stop_ = true;
    84     //     return true;
    85     // }
    86     // bool ActionpointController::go(bool bTriggered, BaseObject* trigger)
    87     // {
    88     //     this->stop_ = false;
    89     //     return true;
    90     // }
     71
    9172    ActionpointController::~ActionpointController()
    9273    {
     
    9576        actionpoints_.clear();
    9677        this->actionpointControllerId_ = 0;
    97         /*ActionpointController::nextActionpointControllerId_--;
    98         if (ActionpointController::nextActionpointControllerId_ < 0)
    99             ActionpointController::nextActionpointControllerId_ = 0;*/
     78
    10079    }
    10180    void ActionpointController::tick(float dt)
    10281    {
    103         if (!this || !this->getControllableEntity() || !this->isActive())
     82        if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_)
    10483            return;
    10584        ++this->ticks_;
     
    126105            //orxout (internal_error) << "first tick was called by id = " << this->actionpointControllerId_ << ", total = " << ActionpointController::nextActionpointControllerId_ << endl;
    127106        }
    128         if (ActionpointController::sTicks_ == 1)
    129         {   
    130             this->bActionCalled_ = false;
    131            
    132             this->bFirstTick_ = false;
    133         }
    134 /*        if (ActionpointController::sTicks_ % (ActionpointController::nextActionpointControllerId_+1) != this->actionpointControllerId_)
    135         {
    136             return;
    137         }*/
     107
    138108        if (!this || !this->getControllableEntity())
    139109            return;
     
    151121        if (!this || !this->getControllableEntity())
    152122            return;
    153        
    154         if (stop_)
    155             return;
    156        
    157123
    158124        if (timeout_ <= 0)
     
    223189        if (!this || !this->getControllableEntity())
    224190            return;
    225         if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
    226             return;
     191
    227192        if (this->bDefaultPatrol_ || (this->action_ != Action::FLY && this->action_ != Action::NONE))
    228193        {
     
    232197            return;
    233198
    234 
    235         if (!this || !this->getControllableEntity())
    236             return;
    237 
    238         // if (this->actionCounter_ % 2 == 0)
    239199        //No action -> pop one from stack
    240200        if (this->action_ == Action::NONE || this->bTakenOver_)
     
    247207            this->executeActionpoint();
    248208            this->bTakenOver_ = false;
    249             // this->action();
    250209        }
    251210        if (!this || !this->getControllableEntity())
     
    262221                {
    263222                    this->setAction (Action::FIGHTALL, newTarget);
    264                     //this->action();
    265223                }
    266224                else
     
    284242                {
    285243                    this->setAction (Action::FIGHT, newTarget);
    286                     //this->action();
    287244                }
    288245                else
     
    760717        }
    761718    }
    762     int ActionpointController::nextActionpointControllerId_ = 0;
    763     int ActionpointController::sTicks_ = 0;
     719    unsigned int ActionpointController::nextActionpointControllerId_ = 0;
     720    unsigned int ActionpointController::sTicks_ = 0;
    764721}   
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h

    r10934 r10935  
    170170            bool getDefaultPatrol ()
    171171                { return this->bDefaultPatrol_; }
    172                  // Trigger interface
    173             // bool stop(bool bTriggered, BaseObject* trigger);
    174             // bool go(bool bTriggered, BaseObject* trigger);
    175             // virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
     172               
    176173
    177174            virtual void stayNearProtect();
     
    243240                void nextActionpoint();                 
    244241            //----[Actionpoint methods]----         
    245                 bool bFirstTick_;
    246 
    247               /*  void setSpawners();
    248                 Vector3 bestHealthPickup (float searchRadius);
    249                 // Point closestPickup(PickupType::Value pickupType);
    250                 std::multimap <int, std::pair<PickupSpawner*, bool> > healthSpawners_;
    251                 std::multimap <int, std::pair<PickupSpawner*, bool> > damageSpawners_;
    252                 std::multimap <int, std::pair<PickupSpawner*, bool> > speedSpawners_;
    253 */
    254                 bool bActionCalled_;
    255                 bool bManeuverCalled_;
     242
    256243                bool bDefaultFightAll_;
    257244
    258                 bool bActive_;
    259245                bool bPatrolling_;
    260246                bool bDefaultPatrol_;
    261247                bool stop_;
    262                 static int sTicks_;
    263                 static int nextActionpointControllerId_;
    264                 int actionpointControllerId_;
    265                 int ticks_;
     248                static unsigned int sTicks_;     //<! a hack? I don't want action() and maneuver() to be called multiple times in a tick, so I keep
     249                                        //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action()
     250                static unsigned int nextActionpointControllerId_;    //<! if level has 16 ActionpointControllers, than this variable equals to 17 after first tick
     251                unsigned int actionpointControllerId_;   //<! integer from 0 to nextActionpointControllerId_, different for every ActionpointController in level
     252                unsigned int ticks_;     //<! local tick counter
    266253
    267254
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10923 r10935  
    4343        this->myFollower_ = 0;
    4444        this->myWingman_ = 0;
    45         //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
    4645    }
    4746
     
    6160        SUPER(DivisionController, XMLPort, xmlelement, mode);
    6261       
    63         //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
    6462    }
    6563    void DivisionController::tick(float dt)
     
    6866            return;   
    6967        SUPER(DivisionController, tick, dt);
    70         /*if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
    71         {
    72             this->action();
    73             this->bActionCalled_ = true;
    74         }
    75         if (this->timeOffset_ > 1.6f)
    76         {
    77             this->bActionCalled_ = false;
    78         }*/
    79 
    8068       
    8169    }
  • code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc

    r10934 r10935  
    149149            if (!this || !this->getControllableEntity())
    150150                return;
    151             // if (this->actionCounter_ % 3 == 0)
    152151            if (!this->bDodge_)
    153152            {
     
    286285        if (pawn)
    287286            pawn->setAimPosition (this->positionOfTarget_);
    288         // if (pawn->getHealth() < 100)
    289         //     orxout(internal_error) << "not full, hp = " << pawn->getHealth() << endl;
     287
    290288        int firemode;
    291289        float distance = CommonController::distance (this->getControllableEntity(), this->target_);
    292290
    293         // firemode = distance < 1500 ? (distance > 800 && distance < 1200 ?
    294         //                             (this->rocketsLeft_ > 0 && !this->bFiredRocket_ ? getFiremode("RocketFire") : getFiremode ("HsW01"))
    295         //                                                      : getFiremode("HsW01")) :
    296         //                                                      (distance < 2500 ? getFiremode("LightningGun") : getFiremode("HsW01"));
     291
     292       
    297293        if (distance < 1500)
    298294        {
     
    310306
    311307        }
    312         // else if (distance < 1000)
    313         // {
    314         //     if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
    315         //     {
    316         //         firemode = getFiremode ("RocketFire");
    317         //     }
    318         //     else
    319         //     {
    320         //         firemode = getFiremode ("HsW01");
    321         //     }
    322         // }
     308   
     309
    323310        else if (distance < 2000)
    324311        {
     
    377364        }
    378365
    379         //orxout (internal_error) << this->rocketsLeft_ << " rockets left" << endl;
    380366    }
    381367
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10925 r10935  
    2828
    2929#include "SectionController.h"
    30 //TODO: formation vectors are wrong, fix it.
    31 // split classes.
    32 // weaponsystem.
    33 //-> Math ?
    34  
     30
    3531namespace orxonox
    3632{
     
    4440        this->setFormationMode(FormationMode::FINGER4);
    4541
    46         //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
    4742        this->myWingman_ = 0;
    4843        this->myDivisionLeader_ = 0;
    4944        this->bFirstAction_ = true;
    50         //orxout(internal_error) << this << "Was created" << endl;
    5145
    5246    }
     
    7468   
    7569        SUPER(SectionController, tick, dt);
    76         /*if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
    77         {
    78             this->action();
    79             this->bActionCalled_ = true;
    80         }
    81         if (this->timeOffset_ > 2.0f)
    82         {
    83             this->bActionCalled_ = false;
    84         }*/
    85 
     70       
    8671    }
    8772
     
    137122                {
    138123                    this->chooseTarget();
    139                     //orxout (internal_error) << "Section ain't got no target" << endl;
    140124                }
    141                 if (this->hasTarget())
    142                 {
    143                     // this->maneuver();
    144                     // this->bShooting_ = this->canFire();
    145                     // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
    146                     // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
    147                     // {
    148                     //     //----choose where to go----
    149                     //     this->maneuver();
    150                     // }
    151                     // else
    152                     // {
    153                     //     this->dodgeTowards(healthPosition);
    154                     // }
    155                     // //----fire if you can----
    156                     // this->bShooting_ = this->canFire();               
    157                 }
     125
    158126            }
    159127        }
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.h

    r10915 r10935  
    6767        private:
    6868            //----private variables-----
    69                 Timer actionTimer_; //<! Regularly calls action().
    7069                bool bFirstAction_;
    7170               
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10925 r10935  
    3939    {
    4040        RegisterObject(WingmanController);
    41         //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
    4241        this->myLeader_ = 0;
    4342        this->bFirstAction_ = true;
     
    6867       
    6968        SUPER(WingmanController, tick, dt);
    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        
    11069
    11170    }
     
    157116                    this->setTarget(this->myLeader_->getTarget());
    158117                }
    159                 if (this->hasTarget())
    160                 {
    161                     // this->maneuver();
    162                     // this->bShooting_ = this->canFire();
    163                     // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
    164                     // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
    165                     // {
    166                     //     //----choose where to go----
    167                     //     this->maneuver();
    168                     // }
    169                     // else
    170                     // {
    171                     //     this->dodgeTowards(healthPosition);
    172                     // }
    173                     // //----fire if you can----
    174                     // this->bShooting_ = this->canFire();               
    175                 }
     118               
    176119            }
    177120        }
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h

    r10915 r10935  
    6868            //----private variables-----
    6969                WeakPtr<ActionpointController> myLeader_;
    70                 Timer actionTimer_; //<! Regularly calls action().
    7170                bool bFirstAction_;
    7271                float actionTime_;
Note: See TracChangeset for help on using the changeset viewer.