Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 7, 2011, 3:59:54 PM (13 years ago)
Author:
jo
Message:

Adjust weapon behaviour if bot dies and is respawned with a different weaponsetting than before.

File:
1 edited

Legend:

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

    r8733 r8735  
    9090        this->bSetupWorked = false;
    9191        this->numberOfWeapons = 0;
    92         this->botlevel_ = 1.0f;
     92        this->botlevel_ = 0.5f;
    9393        this->mode_ = DEFAULT;////Vector-implementation: mode_.push_back(DEFAULT);
    9494        this->timeout_=0;
     
    10431043        else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f))
    10441044        {
    1045             if (this->isCloseAtTarget(130) &&(weapons[1]==1) )
     1045            if (this->isCloseAtTarget(130) &&weapons[1] )
    10461046            {//LENSFLARE: short range weapon     
    10471047                this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target
    10481048            }
    1049             else if((weapons[3]==3)&& this->isCloseAtTarget(400) /*&&projectiles[3]*/ )
     1049            else if(weapons[3]&& this->isCloseAtTarget(400) /*&&projectiles[3]*/ )
    10501050            {//ROCKET: mid range weapon
    10511051                //TODO: How many rockets are available?
    10521052                this->mode_ = ROCKET;//Vector-implementation: mode_.push_back(ROCKET);
    1053                 this->getControllableEntity()->fire(3);//launch rocket BUG IS TRIGGERED HERE.
     1053                this->getControllableEntity()->fire(3);//launch rocket
    10541054                if(this->getControllableEntity()&&this->target_)//after fire(3) getControllableEntity() refers to the rocket!
    10551055                {
     
    10641064                this->projectiles[3]-=1;//decrease ammo !!
    10651065            }
    1066             else if ((weapons[0]==0))//LASER: default weapon
     1066            else if (weapons[0])//LASER: default weapon
    10671067                this->getControllableEntity()->fire(0);
    10681068        }
     
    10831083                    //const std::string wpn = getWeaponname(i, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info.
    10841084                    /*if(wpn=="")
    1085                         weapons[i]=-1;
     1085                        weapons[i]=false;
    10861086                    else if(wpn=="LaserMunition")//other munitiontypes are not defined yet :-(
    1087                         weapons[0]=0;
     1087                        weapons[0]=true;
    10881088                    else if(wpn=="FusionMunition")
    1089                         weapons[1]=1;
     1089                        weapons[1]=true;
    10901090                    else if(wpn=="TargetSeeking Rockets")
    1091                         weapons[2]=2;
    1092                     else if(wpn=="ROCKET")//TODO: insert right munition name
    1093                         weapons[3]=3;
     1091                        weapons[2]=true;
     1092                    else if(wpn=="RocketMunition")
     1093                        weapons[3]=true;
     1094                    else
     1095                        COUT(1)<< wpn << + << " has to be added in ArtificialController.cc as new weapon." << std::endl;
    10941096                    */
    10951097                    if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment!
    10961098                    {
    1097                         weapons[i]=i;
     1099                        weapons[i]=true;
    10981100                        projectiles[i]=1;//TODO: how to express infinite ammo? how to get data?? getWeaponmode(i)->getMunition()->getNumMunition(WeaponMode* user)
    10991101                          numberOfWeapons++;
    11001102                    }
    11011103                    else
    1102                         weapons[i]=-1;
     1104                        weapons[i]=-false;
    11031105                }
    11041106                 //pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
Note: See TracChangeset for help on using the changeset viewer.