Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10349 in orxonox.OLD for branches/ai/src/ai/ai_team.cc


Ignore:
Timestamp:
Jan 24, 2007, 6:55:21 PM (17 years ago)
Author:
tfahrni
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ai/src/ai/ai_team.cc

    r10290 r10349  
    3030
    3131                if(it->second->taskDone()){
    32                         std::cout << "Swarm Task Complete!\n";
     32                        //std::cout << "Swarm Task Complete!\n";
    3333
    3434                        if(enemyList->size()==0){
     
    5151                        //find new Position
    5252                        if(isPlayer){
     53                                float attackDistance=it->second->getAttackDistance();
     54
    5355                                Vector targetPos=target->getAbsCoor();
    5456                                int zNorm=(position.z>targetPos.z)?1:-1;
    5557
    5658                                if((position.z-targetPos.z)*zNorm>60){  //go to start position
    57                                         std::cout << "Go Start Position\n";
     59                                        //std::cout << "Go Start Position\n";
    5860                                        changeSwarmModule(it, new SwarmGoRel);
    5961                                        zNorm=1-(rand()%2)*2;   //1 or -1
    60                                         newPosition=Vector(190,0,zNorm*10);
     62                                        newPosition=Vector(attackDistance+60,0,zNorm*10);
    6163                                        speed=60;
    62                                 }else if(position.x > targetPos.x+160){ //go to attack position
    63                                         std::cout << "Go Attack Position\n";
     64                                }else if(position.x > targetPos.x+attackDistance+40){   //go to attack position
     65                                        //std::cout << "Go Attack Position\n";
    6466                                        changeSwarmModule(it, new SwarmGoRel);
    65                                         newPosition=Vector(130,0,0);
     67                                        newPosition=Vector(attackDistance+30,0,0);
    6668                                        speed=60;
    67                                 }else if(position.x > targetPos.x+120){ //go to attack mode
    68                                         std::cout << "Go Attack Mode\n";
     69                                }else if(position.x > targetPos.x+attackDistance+20){   //go to attack mode
     70                                        //std::cout << "Go Attack Mode\n";
    6971                                        changeSwarmModule(it, new SwarmAttack);
    70                                         newPosition=Vector(110,0,0);
     72                                        newPosition=Vector(attackDistance,0,0);
    7173                                        speed=60;
    7274                                        maxTime=(rand()%11)+4;//4-14 Sekunden
    7375                                }else{                                                                                          //go to fallback point
    74                                         std::cout << "Go  Fallback Point\n";
     76                                        //std::cout << "Go  Fallback Point\n";
    7577                                        changeSwarmModule(it, new SwarmGoRel);
    7678                                        newPosition=Vector(80,0,zNorm*90);
     
    106108
    107109
    108 void AITeam::addAI(int swarmNumber, WorldEntity* npc)
     110void AITeam::addAI(int swarmNumber, WorldEntity* npc, float maxSpeed, float attackDistance)
    109111{
    110112        std::pair<std::map<int,SwarmModule*>::iterator,bool> p;
     
    112114        p=swarms.insert(std::make_pair(swarmNumber,newSwarm));
    113115        if(!p.second)delete newSwarm;
    114         p.first->second->addAI(npc);
     116        p.first->second->addAI(npc, maxSpeed, attackDistance);
    115117}
    116118
Note: See TracChangeset for help on using the changeset viewer.