Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 27, 2011, 3:58:04 PM (13 years ago)
Author:
jo
Message:

Now the ai use lensflare if the weapon is on board and if they are close enough to the target. Hardcoded version!

File:
1 edited

Legend:

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

    r7401 r7832  
    8484
    8585        this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
     86        this->bSetupWorked = false;
     87        this->numberOfWeapons = 0;
    8688    }
    8789
     
    10161018        return (team1 == team2 && team1 != -1);
    10171019    }
     1020   
     1021    void ArtificialController::doFire()
     1022    {
     1023        if(!bSetupWorked)//setup: find out which weapons are active ! hard coded: laser is "0", lens flare is "1", ...
     1024        {
     1025            this->setupWeapons();
     1026            if(numberOfWeapons>0)
     1027                bSetupWorked=true;
     1028        }
     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) )
     1032                this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target
     1033
     1034          //default fire (laser)
     1035          else if ((weapons[0]==0))
     1036               this->getControllableEntity()->fire(0);
     1037        }
     1038    }
     1039    void ArtificialController::setupWeapons()
     1040    {
     1041        if(this->getControllableEntity())
     1042        {
     1043            Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
     1044            if(pawn)
     1045            {
     1046                 for(unsigned int i=0; i<WeaponSystem::MAX_WEAPON_MODES; i++)
     1047                 {
     1048                      if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment!
     1049                      {
     1050                          weapons[i]=i;
     1051                          numberOfWeapons++;
     1052                      }
     1053                      else
     1054                          weapons[i]=-1;
     1055                 }
     1056            }
     1057        }
     1058    }
    10181059}
Note: See TracChangeset for help on using the changeset viewer.