Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10974 for code/branches


Ignore:
Timestamp:
Dec 14, 2015, 11:31:30 AM (9 years ago)
Author:
maxima
Message:

merged campaign and presentation

Location:
code/branches/presentationHS15
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS15

  • code/branches/presentationHS15/data/levels/AITest.oxw

    r10970 r10974  
    162162<!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
    163163<!-- HERE STARTS DEMO FOR FIGHTING -->
    164     <!--
     164   
    165165
    166166    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
     
    238238        </WingmanController>
    239239      </controller>
    240     </SpaceShip>  -->
     240    </SpaceShip>
    241241
    242242<!-- HERE ENDS DEMO FOR FIGHTING -->
    243243<!-- HERE STARTS DEMO FOR FORMATIONS -->
    244    
     244    <!--
    245245    <Model mesh="cube.mesh" scale=8 position="   0,2000,    0" />
    246246    <Model mesh="cube.mesh" scale=8 position="   0,2000,-2000" />
     
    291291      </controller>
    292292    </SpaceShip>
    293    
     293    -->
    294294<!-- HERE ENDS DEMO FOR FORMATIONS -->
    295295    <!-- 1 division is roughly equal to 6 AIControllers--!>
  • code/branches/presentationHS15/src/orxonox/controllers/ActionpointController.cc

    r10970 r10974  
    5353        this->bDefaultPatrol_ = true;
    5454        this->bDefaultFightAll_ = true;
    55         this->stop_ = false;
    5655        RegisterObject(ActionpointController);
    5756
     
    7574    void ActionpointController::tick(float dt)
    7675    {
    77         if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_)
     76        if (!this || !this->getControllableEntity() || !this->isActive())
    7877            return;
    7978
     
    733732        if (!this || !this->getControllableEntity())
    734733            return;
    735 
    736         //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
    737         {
    738             if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
    739             {
    740                 if (!this || !this->getControllableEntity())
    741                     return;
    742                 Pawn* newTarget = this->closestTarget();
    743                 if ( newTarget &&
    744                     CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
    745                         <= this->attackRange_ )
    746                 {
    747                     if (!this || !this->getControllableEntity())
    748                         return;
    749                     this->setTarget(newTarget);
    750                     if (this->bLoop_ && !this->bPatrolling_)
    751                     {
    752                         Point p = { Action::FIGHT, "", Vector3::ZERO, true };
    753                         this->loopActionpoints_.push_back(p);
    754                     }
    755                     else if (!this->bPatrolling_)
    756                     {
    757                         //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
    758                         Point p = { Action::FIGHT, "", Vector3::ZERO, false };
    759                         this->parsedActionpoints_.push_back(p);
    760                     }
    761                     this->bPatrolling_ = true;
    762                     this->executeActionpoint();
    763                 }
     734       
     735        if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
     736        {
     737            if (!this || !this->getControllableEntity())
     738                return;
     739            Pawn* newTarget = this->closestTarget();
     740            if ( newTarget &&
     741                CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
     742                    <= this->attackRange_ )
     743            {
     744                if (!this || !this->getControllableEntity())
     745                    return;
     746                this->setTarget(newTarget);
     747                if (this->bLoop_ && !this->bPatrolling_)
     748                {
     749                    Point p = { Action::FIGHT, "", Vector3::ZERO, true };
     750                    this->loopActionpoints_.push_back(p);
     751                }
     752                else if (!this->bPatrolling_)
     753                {
     754                    Point p = { Action::FIGHT, "", Vector3::ZERO, false };
     755                    this->parsedActionpoints_.push_back(p);
     756                }
     757                this->bPatrolling_ = true;
     758                this->executeActionpoint();
    764759            }
    765760        }
  • code/branches/presentationHS15/src/orxonox/controllers/ActionpointController.h

    r10970 r10974  
    6363    @note
    6464        ActionpointController will not work, if there is no MasterController in the level!
     65        All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level.
    6566    */
    6667    namespace Action
     
    216217                std::vector<Point > parsedActionpoints_;//<! actionpoints as they are stored here after being parsed from XML
    217218                std::vector<Point > loopActionpoints_;  //<! actionpoints that are to be looped
    218                 bool bInLoop_;
     219                bool bInLoop_;                          //<! variable for addActionpoint method
    219220                bool bLoop_;                            //<! is state machine looping?
    220                 bool bEndLoop_;                   
     221                bool bEndLoop_;                         //<! variable for addActionpoint method
    221222                bool bTakenOver_;                       //<! are actionpoints taken over from the leader when he died? if yes, top actionpoint
    222223                                                        //<! is to be executed for the state machine to start working
     
    250251            //----[Actionpoint methods]----         
    251252
    252                 bool bDefaultFightAll_;
    253 
    254                 bool bPatrolling_;
    255                 bool bDefaultPatrol_;
    256                 bool stop_;
     253                bool bDefaultFightAll_;     //<! if true, when no action set, this will fight all
     254
     255                bool bPatrolling_;        //<! true if current action_ is FIGHT because this found enemies that are close, need this to correctly go back to looping if was looping
     256                bool bDefaultPatrol_;       //<! if true, this will look out for enemies that are close if this is just flying or doing nothing
    257257                unsigned int ticks_;     //<! local tick counter           
    258 
    259258    };
    260259}
  • code/branches/presentationHS15/src/orxonox/controllers/CommonController.cc

    r10970 r10974  
    2323 *      Gani Aliguzhinov
    2424 *   Co-authors:
    25  *      Dominik Solenicki
     25 *      ...
    2626 *
    2727 */
     
    7373    bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    7474    {
    75         //uncomment following code if functions stops working due to being a hack
    76         /*if (!entity1 || !entity2)
    77             return false;
    78         return entity1->getTeam() == entity2->getTeam();*/
     75       
    7976        if (!entity1 || !entity2)
    8077            return false;
  • code/branches/presentationHS15/src/orxonox/controllers/CommonController.h

    r10970 r10974  
    2323 *      Gani Aliguzhinov
    2424 *   Co-authors:
    25  *      Dominik Solenicki
     25 *      ...
    2626 *
    2727 */
     
    4949            CommonController(Context* context);
    5050            virtual ~CommonController();
    51             static float randomInRange(float a, float b);
    52             static float distance(const ControllableEntity* entity1, const ControllableEntity* entity2);
     51            static float randomInRange(float a, float b);   //<! returns random number from a to b
     52            static float distance(const ControllableEntity* entity1, const ControllableEntity* entity2);    //<! returns distance between arguments
    5353            static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt);
    54             static bool isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle ) ;
    55             static std::string getName(const Pawn* entity ) ;           
     54            static bool isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle) ;
     55            static std::string getName(const Pawn* entity) ;           
    5656    };
    5757}
  • code/branches/presentationHS15/src/orxonox/controllers/DivisionController.cc

    r10970 r10974  
    7979        if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
    8080        {
     81            //when this dies, its follower will execute all its actionpoints, if follower dies before this, wingman will do this
    8182            if (this->myFollower_)
    8283            {
  • code/branches/presentationHS15/src/orxonox/controllers/DivisionController.h

    r10970 r10974  
    3939        @note
    4040        ActionpointController will not work, if there is no MasterController in the level!
     41        All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level.
    4142    */
    4243    class _OrxonoxExport DivisionController : public ActionpointController
  • code/branches/presentationHS15/src/orxonox/controllers/FightingController.cc

    r10970 r10974  
    151151            if (!this->bDodge_)
    152152            {
    153                 // orxout(internal_error) << "attacking" << endl;
    154153                this->bStartedDodging_ = false;
    155154
     
    159158            else if (bTargetIsLookingAtThis || diffLength < 700.0f)
    160159            {
    161                 // orxout(internal_error) << "dodging" << endl;
    162160                if (!this->bStartedDodging_)
    163161                {
     
    170168                if (diffLength < 1000)
    171169                {
    172                 // orxout(internal_error) << "looking" << endl;                   
    173170                    this->stopMoving();
    174171                    this->startLookingAtTarget();
     
    177174                else
    178175                {
    179                 // orxout(internal_error) << "closing up" << endl;                   
    180176                    this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
    181177                }
     
    354350                        if (wName == "RocketFire")
    355351                            this->rocketsLeft_ = 10;
    356                             // this->rocketsLeft_ = orxonox_cast<Pawn*>(this->getControllableEntity())->getWeaponSystem()->getMunition(&munition)->getNumMunitionInCurrentMagazine(wMode);
    357352                        if(this->getFiremode(wName) == -1) //only add a weapon, if it is "new"
    358353                            weaponModes_[wName] = wMode->getMode();
     
    361356                if(weaponModes_.size())//at least one weapon detected
    362357                    this->bSetupWorked = true;
    363             }//pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
     358            }
    364359        }
    365360
  • code/branches/presentationHS15/src/orxonox/controllers/MasterController.cc

    r10970 r10974  
    3838    {
    3939        RegisterObject(MasterController);
    40         // orxout(internal_error) << "MasterController was created" << endl;
    41 
    4240        this->controllers_.clear();
    4341        this->numberOfTicksPassedSinceLastActionCall_ = 0;
     
    5048        this->controllers_.clear();
    5149    }
     50    /*HACK*/
     51    //the whole idea is a hack
    5252    void MasterController::tick(float dt)
    5353    {   
     
    5555            return; 
    5656        ++this->ticks_;
    57         //orxout(internal_error) << "Tick = " << this->ticks_ << endl;
    5857        if (this->ticks_ == 1)
    5958        {
     
    6665                this->controllers_.push_back(*it);
    6766            }
    68             //orxout(internal_error) << "I got " << this->controllers_.size() << " controllers" << endl;
    6967        }
    7068        else
    7169        {
    72 
    7370            if (this->controllers_.empty())
    7471                return;
     
    8784            if (this->numberOfTicksPassedSinceLastActionCall_ > 0)
    8885            {
    89                 //call maneuver for current index
    9086                if (this->numberOfTicksPassedSinceLastActionCall_ == 3)
    9187                {
     88                    //check if 0ptr
    9289                    if (!this->controllers_.at(this->indexOfCurrentController_))
    9390                    {
     
    9592                        return;
    9693                    }
    97                     //orxout (internal_error) << "Executing maneuver of Controller # " << this->indexOfCurrentController_ << endl;
     94                    //call maneuver for current index
    9895                    this->controllers_.at(this->indexOfCurrentController_)->maneuver();
    9996                }
    10097                else if (this->numberOfTicksPassedSinceLastActionCall_ == 6)
    10198                {
    102                     //call canFire for current index
     99                    //check if 0ptr
    103100                    if (!this->controllers_.at(this->indexOfCurrentController_))
    104101                    {
     
    106103                        return;
    107104                    }
    108                     //orxout (internal_error) << "Executing maneuver of Controller # " << this->indexOfCurrentController_ << endl;
     105                    //call canFire for current index
    109106                    this->controllers_.at(this->indexOfCurrentController_)->bShooting_ = this->controllers_.at(this->indexOfCurrentController_)->canFire();   
    110107                }
     
    113110            else
    114111            {
    115                 //call action for current index
     112                //check if 0ptr
    116113                if (!this->controllers_.at(this->indexOfCurrentController_))
    117114                {
     
    119116                    return;
    120117                }
    121                 //orxout (internal_error) << "Executing action of Controller # " << this->indexOfCurrentController_ << endl;
    122                 this->controllers_.at(this->indexOfCurrentController_)->action();   
     118                //call action for current index
     119                this->controllers_.at(this->indexOfCurrentController_)->action();   
     120                 
    123121                //bCopyOrientation makes ship oscillate like crazy if set to true all the time.s
    124122                this->controllers_.at(this->indexOfCurrentController_)->bCopyOrientation_ = this->ticks_ % 3 == 0;
  • code/branches/presentationHS15/src/orxonox/controllers/SectionController.cc

    r10970 r10974  
    8484
    8585            this->myDivisionLeader_ = newDivisionLeader;
    86             //spread copyOrientation called equally among the division
    87 
    8886        }
    8987        //----If have leader----
     
    111109            {
    112110                this->keepFormation();
    113                 //orxout (internal_error) << "Keeping formation" << endl;
    114 
    115111            }
    116112            else if (!this->myDivisionLeader_->bKeepFormation_)
     
    162158                            foundTarget = true;
    163159                            target =  (*itP);
    164                             //orxout(internal_error) << "Found target" << endl;
    165160                            break;
    166161                        }
  • code/branches/presentationHS15/src/orxonox/controllers/SectionController.h

    r10970 r10974  
    3838        @note
    3939        ActionpointController will not work, if there is no MasterController in the level!
     40        All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level.
    4041    */
    4142    class _OrxonoxExport SectionController : public ActionpointController
     
    6667        protected:       
    6768            //----action must only be managed by this----     
    68                 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
     69                virtual void action(); //<! action() is called in regular intervals by MasterController managing the bot's behaviour.
    6970                Vector3 getFormationPosition ();
    7071                void keepFormation();
  • code/branches/presentationHS15/src/orxonox/controllers/WingmanController.cc

    r10970 r10974  
    9999        else if (this->myLeader_)
    100100        {
    101             if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT || this->myLeader_->getAction() == Action::FIGHTALL
     101            if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT
     102                || this->myLeader_->getAction() == Action::FIGHTALL
    102103                || this->myLeader_->getAction() == Action::ATTACK))
    103104            {
     
    148149        else
    149150        {
    150 
    151151            switch (this->formationMode_){
    152152                case FormationMode::WALL:
     
    215215        {
    216216            //----Racing conditions----
     217            /*TODO: racing condition check is wrong and redundant, as there is no multithreading here, ticks get called one after another,
     218            so it can be simplified to a check of whether leader got a wingman*/
    217219            if (closestLeader->setWingman(orxonox_cast<ActionpointController*>(this)))
    218220            {
    219                 if (closestLeader->getIdentifier()->getName() == "SectionController")
    220                 {
    221                     this->actionTime_ = 1.6f;
    222                 }
    223                 else
    224                 {
    225                     this->actionTime_ = 2.0f;
    226                 }
    227221                return closestLeader;
    228222            }
  • code/branches/presentationHS15/src/orxonox/controllers/WingmanController.h

    r10970 r10974  
    3939        @note
    4040        ActionpointController will not work, if there is no MasterController in the level!
     41        All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level.
    4142    */
    4243    class _OrxonoxExport WingmanController : public ActionpointController
     
    7374                WeakPtr<ActionpointController> myLeader_;
    7475                bool bFirstAction_;
    75                 float actionTime_;
    7676
    7777
Note: See TracChangeset for help on using the changeset viewer.