Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7843 for code/branches/ai


Ignore:
Timestamp:
Feb 3, 2011, 5:46:31 PM (14 years ago)
Author:
jo
Message:

Little feature added: Bot's are following their victims. So that they can't get out of reach easily.

Location:
code/branches/ai/src/orxonox/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/src/orxonox/controllers/AIController.cc

    r7842 r7843  
    2626 *
    2727 */
    28 //TODO: intended behaviour: when a bot has a target_ it shouldn't move away.
     28
    2929#include "AIController.h"
    3030
     
    3535#include "worldentities/pawns/Pawn.h"
    3636
     37//Todo: Bot soll pickupspawner besuchen können, falls Pickup vorhanden
    3738namespace orxonox
    3839{
     
    8687            // next enemy
    8788            random = rnd(maxrand);
    88             if (random < ((1+ botlevel_)*10) && (this->target_))
     89            if (random < ((1-botlevel_)*10) && (this->target_))
    8990                this->searchNewTarget();
    9091
     
    159160                // search enemy
    160161                random = rnd(maxrand);
    161                 if (random < 15 && (!this->target_))
     162                if (random < (botlevel_)*25 && (!this->target_))
    162163                    this->searchNewTarget();
    163164
    164165                // forget enemy
    165166                random = rnd(maxrand);
    166                 if (random < 5 && (this->target_))
     167                if (random < (1-botlevel_)*6 && (this->target_))
    167168                    this->forgetTarget();
    168169
     
    184185                // shoot
    185186                random = rnd(maxrand);
    186                 if (!(this->passive_) && random < 9 && (this->target_ && !this->bShooting_))
     187                if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_))
    187188                {
    188                 this->bShooting_ = true;
    189                 this->forceFreeSlaves();
     189                    this->bShooting_ = true;
     190                    this->forceFreeSlaves();
    190191                }
    191192
     
    202203    void AIController::tick(float dt)
    203204    {
     205        float random;
     206        float maxrand = 100.0f / ACTION_INTERVAL;
     207       
    204208        if (!this->isActive())
    205209            return;
     
    213217                    if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
    214218                        this->forgetTarget();
    215                     else this->aimAtTarget();
     219                    else
     220                    {
     221                        this->aimAtTarget();
     222                        random = rnd(maxrand);
     223                        if(this->botlevel_*100 > random)
     224                            this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
     225                    }
    216226                }
    217227
     
    233243        if (this->state_ == SLAVE)
    234244        {
    235 
    236245            if (this->bHasTargetPosition_)
    237246                this->moveToTargetPosition();
    238 
    239247        }
    240248
     
    245253                if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
    246254                    this->forgetTarget();
    247                 else this->aimAtTarget();
     255                else
     256                {
     257                    this->aimAtTarget();
     258                    random = rnd(maxrand);
     259                    if(this->botlevel_*100 > random)
     260                        this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
     261                }
    248262            }
    249263
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r7842 r7843  
    5353    SetConsoleCommand("ArtificialController", "formationsize",    &ArtificialController::formationsize);
    5454    SetConsoleCommand("ArtificialController", "setbotlevel",      &ArtificialController::setAllBotLevel);
    55    
    5655
    5756    static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
     
    131130        XMLPortParam(ArtificialController, "formationSize", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE);
    132131        XMLPortParam(ArtificialController, "passive", setPassive, getPassive, xmlelement, mode).defaultValues(false);
    133         XMLPortParam(ArtificialController, "level", setBotLevel, getBotLevel, xmlelement, mode).defaultValues(1.0f);
     132        //XMLPortParam(ArtificialController, "level", setBotLevel, getBotLevel, xmlelement, mode).defaultValues(0.0f);
    134133    }
    135134
     
    10331032                bSetupWorked=true;
    10341033        }
    1035         else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget(1000 + botlevel_*200) && this->isLookingAtTarget(math::pi / 20.0f))
     1034        else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f))
    10361035        {
    10371036            if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) )
Note: See TracChangeset for help on using the changeset viewer.