Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 27, 2011, 7:50:16 PM (13 years ago)
Author:
jo
Message:

The ai's strength can be modified by changing the value botlevel_ . The level can be adjusted between 1 (weak) and 10 (strong).
The next step is adding xml and console command functionality.

File:
1 edited

Legend:

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

    r7832 r7833  
    8686        this->bSetupWorked = false;
    8787        this->numberOfWeapons = 0;
     88        this->botlevel_ = 10.0f;
    8889    }
    8990
     
    128129        XMLPortParam(ArtificialController, "formationSize", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE);
    129130        XMLPortParam(ArtificialController, "passive", setPassive, getPassive, xmlelement, mode).defaultValues(false);
     131        XMLPortParam(ArtificialController, "level", setBotLevel, getBotLevel, xmlelement, mode).defaultValues(1.0f);
    130132    }
    131133
     
    10181020        return (team1 == team2 && team1 != -1);
    10191021    }
    1020    
     1022    /**
     1023        @brief DoFire is called when a bot should shoot and decides which weapon is used and whether the bot shoots at all.
     1024    */
    10211025    void ArtificialController::doFire()
    10221026    {
     
    10271031                bSetupWorked=true;
    10281032        }
    1029         else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
    1030         {
    1031             if (this->isCloseAtTarget(140) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) )
     1033        else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget(1000 + botlevel_*200) && this->isLookingAtTarget(math::pi / 20.0f))
     1034        {
     1035            if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) )
    10321036                this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target
    10331037
     
    10371041        }
    10381042    }
     1043    /**
     1044        @brief Information gathering: Which weapons are ready to use?
     1045    */
    10391046    void ArtificialController::setupWeapons()
    10401047    {
     
    10571064        }
    10581065    }
     1066   
     1067    void ArtificialController::setBotLevel(float level)
     1068    {
     1069        if (level < 1)
     1070            this->botlevel_ = 1 ;
     1071        else if (level > 10)
     1072            this->botlevel_ = 10;
     1073        else
     1074            this->botlevel_ = level;
     1075    }
    10591076}
Note: See TracChangeset for help on using the changeset viewer.