Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2011, 2:38:37 PM (12 years ago)
Author:
jo
Message:

teamgametype merged into trunk

Location:
code/branches/presentation2011
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2011

  • code/branches/presentation2011/src/orxonox/controllers/AIController.cc

    r8891 r8980  
    7474            }
    7575
    76             // search enemy
    77             random = rnd(maxrand);
    78             if (random < (15 + botlevel_* 20) && (!this->target_))
    79                 this->searchNewTarget();
    80 
    81             // forget enemy
    82             random = rnd(maxrand);
    83             if (random < ((1-botlevel_)*6) && (this->target_))
    84                 this->forgetTarget();
    85 
    86             // next enemy
    87             random = rnd(maxrand);
    88             if (random < (botlevel_*20) && (this->target_))
    89                 this->searchNewTarget();
    90 
    91             // fly somewhere
    92             random = rnd(maxrand);
    93             if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
    94                 this->searchRandomTargetPosition();
    95 
    96             // stop flying
    97             random = rnd(maxrand);
    98             if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
    99                 this->bHasTargetPosition_ = false;
    100 
    101             // fly somewhere else
    102             random = rnd(maxrand);
    103             if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
    104                 this->searchRandomTargetPosition();
    105 
    106             // shoot
    107             random = rnd(maxrand);
    108             if (!(this->passive_) && random < (75 + botlevel_*25) && (this->target_ && !this->bShooting_))
    109                 this->bShooting_ = true;
    110 
    111             // stop shooting
    112             random = rnd(maxrand);
    113             if (random < ((1 - botlevel_)*25) && (this->bShooting_))
    114                 this->bShooting_ = false;
    115 
    116             // boost
    117             random = rnd(maxrand);
    118             if (random < botlevel_*100 )
    119                 this->boostControl();
    120 
    121             // update Checkpoints
    122             /*random = rnd(maxrand);
    123             if (this->defaultWaypoint_ && random > (maxrand-10))
    124                 this->manageWaypoints();
    125             else //if(random > maxrand-10) //CHECK USABILITY!!*/
    126             if (this->waypoints_.size() == 0 )
    127                 this->manageWaypoints();
    128 
     76            this->defaultBehaviour(maxrand);
    12977        }
    13078
     
    13684        if (this->state_ == MASTER)
    13785        {
    138 
    139 
    14086            this->commandSlaves();
    14187
     
    170116                    this->searchNewMaster();
    171117
    172                 // search enemy
    173                 random = rnd(maxrand);
    174                 if (random < (botlevel_)*25 && (!this->target_))
    175                     this->searchNewTarget();
    176 
    177                 // forget enemy
    178                 random = rnd(maxrand);
    179                 if (random < (1-botlevel_)*6 && (this->target_))
    180                     this->forgetTarget();
    181 
    182                 // next enemy
    183                 random = rnd(maxrand);
    184                 if (random < 10 && (this->target_))
    185                     this->searchNewTarget();
    186 
    187                 // fly somewhere
    188                 random = rnd(maxrand);
    189                 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
    190                     this->searchRandomTargetPosition();
    191 
    192 
    193                 // fly somewhere else
    194                 random = rnd(maxrand);
    195                 if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
    196                     this->searchRandomTargetPosition();
    197 
    198                 // shoot
    199                 random = rnd(maxrand);
    200                 if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_))
    201                 {
    202                     this->bShooting_ = true;
    203                     this->forceFreeSlaves();
    204                 }
    205 
    206                 // stop shooting
    207                 random = rnd(maxrand);
    208                 if (random < ( (1- botlevel_)*25 ) && (this->bShooting_))
    209                     this->bShooting_ = false;
    210 
    211                 // boost
    212                 random = rnd(maxrand);
    213                 if (random < botlevel_*100 )
    214                     this->boostControl();
    215 
    216                 // update Checkpoints
    217                 /*random = rnd(maxrand);
    218                 if (this->defaultWaypoint_ && random > (maxrand-10))
    219                     this->manageWaypoints();
    220                 else //if(random > maxrand-10) //CHECK USABILITY!!*/
    221                 if (this->waypoints_.size() == 0 )
    222                     this->manageWaypoints();
     118                this->defaultBehaviour(maxrand);
    223119            }
    224120        }
    225 
    226121    }
    227122
     
    321216        {   //Vector-implementation: mode_.back() == ROCKET;
    322217            if(controllable)
    323             {
    324                 if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over.
     218            {//Check wether the bot is controlling the rocket and if the timeout is over.
     219                if(controllable->getIdentifier() == ClassByString("Rocket"))
     220
    325221                {
    326222                    this->follow();
     
    342238    }
    343239
     240    void AIController::defaultBehaviour(float maxrand)
     241    {       float random;
     242            // search enemy
     243            random = rnd(maxrand);
     244            if (random < (botlevel_* 100) && (!this->target_))
     245                this->searchNewTarget();
     246
     247            // forget enemy
     248            random = rnd(maxrand);
     249            if (random < ((1-botlevel_)*20) && (this->target_))
     250                this->forgetTarget();
     251
     252            // next enemy
     253            random = rnd(maxrand);
     254            if (random < (botlevel_*30) && (this->target_))
     255                this->searchNewTarget();
     256
     257            // fly somewhere
     258            random = rnd(maxrand);
     259            if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
     260                this->searchRandomTargetPosition();
     261
     262            // stop flying
     263            random = rnd(maxrand);
     264            if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
     265                this->bHasTargetPosition_ = false;
     266
     267            // fly somewhere else
     268            random = rnd(maxrand);
     269            if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
     270                this->searchRandomTargetPosition();
     271
     272            if (this->state_ == MASTER) // master: shoot
     273            {
     274                random = rnd(maxrand);
     275                if (!(this->passive_) && random < (100*botlevel_) && (this->target_ && !this->bShooting_))
     276                {
     277                    this->bShooting_ = true;
     278                    this->forceFreeSlaves();
     279                }
     280            }
     281            else
     282            {
     283                // shoot
     284                random = rnd(maxrand);
     285                if (!(this->passive_) && random < (botlevel_*100) && (this->target_ && !this->bShooting_))
     286                    this->bShooting_ = true;
     287            }
     288
     289            // stop shooting
     290            random = rnd(maxrand);
     291            if (random < ((1 - botlevel_)*50) && (this->bShooting_))
     292                this->bShooting_ = false;
     293
     294            // boost
     295            random = rnd(maxrand);
     296            if (random < botlevel_*50 )
     297                this->boostControl();
     298
     299            // update Checkpoints
     300            /*random = rnd(maxrand);
     301            if (this->defaultWaypoint_ && random > (maxrand-10))
     302                this->manageWaypoints();
     303            else //if(random > maxrand-10) //CHECK USABILITY!!*/
     304            if (this->waypoints_.size() == 0 )
     305                this->manageWaypoints();
     306    }
     307
    344308}
  • code/branches/presentation2011/src/orxonox/controllers/AIController.h

    r8729 r8980  
    4444            virtual ~AIController();
    4545
    46             virtual void tick(float dt);
     46            virtual void tick(float dt); //<! Carrying out the targets set in action().
    4747
    4848        protected:
    49             virtual void action();
     49            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
     50            void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
    5051
    5152        private:
    5253            static const float ACTION_INTERVAL;
    5354
    54             Timer actionTimer_;
     55            Timer actionTimer_; //<! Regularly calls action().
    5556    };
    5657}
  • code/branches/presentation2011/src/orxonox/controllers/ArtificialController.cc

    r8892 r8980  
    4242#include "gametypes/TeamDeathmatch.h"
    4343#include "gametypes/Dynamicmatch.h"
     44#include "gametypes/Mission.h"
    4445#include "controllers/WaypointPatrolController.h"
    4546#include "controllers/NewHumanController.h"
     
    9293        this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
    9394        this->bSetupWorked = false;
    94         this->botlevel_ = 0.2f;
     95        this->botlevel_ = 0.5f;
    9596        this->mode_ = DEFAULT;////Vector-implementation: mode_.push_back(DEFAULT);
    9697        this->timeout_ = 0;
     
    998999        }
    9991000
     1001        Mission* miss = orxonox_cast<Mission*>(gametype);
     1002        if (miss)
     1003        {
     1004            if (entity1->getPlayer())
     1005                team1 = miss->getTeam(entity1->getPlayer());
     1006
     1007            if (entity2->getPlayer())
     1008                team2 = miss->getTeam(entity2->getPlayer());
     1009        }
     1010
    10001011        TeamBaseMatchBase* base = 0;
    10011012        base = orxonox_cast<TeamBaseMatchBase*>(entity1);
     
    11101121        {
    11111122            Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
    1112             if(pawn)
     1123            if(pawn && pawn->isA(Class(SpaceShip))) //fix for First Person Mode: check for SpaceShip
    11131124            {
    11141125                this->weaponModes_.clear(); // reset previous weapon information
  • code/branches/presentation2011/src/orxonox/controllers/ArtificialController.h

    r8891 r8980  
    5151            void abandonTarget(Pawn* target);
    5252
    53             inline void setTeam(int team)
     53            inline void setTeam(int team) //TODO: write through to controllable entity.
    5454                { this->team_ = team; }
    5555            inline int getTeam() const
  • code/branches/presentation2011/src/orxonox/controllers/HumanController.cc

    r8858 r8980  
    195195            this->boosting_ = true;
    196196            this->boostingTimeout_.startTimer();
    197            
    198             this->controllableEntity_->boost(this->boosting_);
     197            if(this->controllableEntity_)
     198                this->controllableEntity_->boost(this->boosting_);
    199199//            orxout() << "Start boosting" << endl;
    200200        }
     
    209209        this->boosting_ = false;
    210210        this->boostingTimeout_.stopTimer();
    211 
    212         this->controllableEntity_->boost(this->boosting_);
     211        if(this->controllableEntity_)
     212            this->controllableEntity_->boost(this->boosting_);
    213213//        orxout() << "Stop boosting" << endl;
    214214    }
  • code/branches/presentation2011/src/orxonox/controllers/WaypointPatrolController.cc

    r7184 r8980  
    4242        RegisterObject(WaypointPatrolController);
    4343
    44         //this->team_ = 0;
    4544        this->alertnessradius_ = 500;
    4645
     
    5352
    5453        XMLPortParam(WaypointPatrolController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
    55 //        XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
    5654    }
    5755
  • code/branches/presentation2011/src/orxonox/controllers/WaypointPatrolController.h

    r7163 r8980  
    4646            virtual void tick(float dt);
    4747
    48            /* inline void setTeam(int team)
    49                 { this->team_ = team; }
    50             inline int getTeam() const
    51                 { return this->team_; } */
    52 
    5348            inline void setAlertnessRadius(float radius)
    5449                { this->alertnessradius_ = radius; }
     
    5954            void searchEnemy();
    6055
    61             //int team_;
    6256            float alertnessradius_;
    6357            Timer patrolTimer_;
Note: See TracChangeset for help on using the changeset viewer.