Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10615 in orxonox.OLD for branches/cleanup


Ignore:
Timestamp:
Mar 30, 2007, 12:01:21 PM (18 years ago)
Author:
rennerc
Message:

this might fix the/one segfault bug in AI. cannot verify it because cannot reproduce bug

Location:
branches/cleanup/src/ai
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/src/ai/swarm_attack.cc

    r10376 r10615  
    3030void SwarmAttack::process(float dt)
    3131{
    32         std::map<WorldEntity*,AIModule*>::iterator it;
     32  WorldEntity* taskRelObject = NULL;
     33  if ( taskRelObjectName != "" )
     34  {
     35    taskRelObject = dynamic_cast<WorldEntity*>(WorldEntity::objectList().getBaseObject( taskRelObjectName ));
     36         
     37         
     38    std::map<WorldEntity*,AIModule*>::iterator it;
     39    Vector sideL=taskRelPos.cross(Vector(0,1,0)).getNormalized();
     40    Vector sideR=sideL*-1;
     41    Vector posL=Vector(0,0,0);
     42    Vector posR=Vector(0,0,0);
     43       
    3344
    34         Vector sideL=taskRelPos.cross(Vector(0,1,0)).getNormalized();
    35         Vector sideR=sideL*-1;
    36         Vector posL=Vector(0,0,0);
    37         Vector posR=Vector(0,0,0);
     45       
     46        //tell positions to swarm-members...
     47    float radius;
     48    Vector objectPos=taskRelObject->getAbsCoor();
    3849
    39         //tell positions to swarm-members...
    40         float radius;
    41         Vector objectPos=taskRelObject->getAbsCoor();
     50    for (it=members.begin(); it!= members.end(); it++ ){
     51      radius=it->second->getNPCRadius();
     52      posR=posR+sideR*radius*1.5;
     53      it->second->setDestination(objectPos+taskRelPos+posR);
     54      it->second->setDestinationMovement(Vector(0,0,0));
     55      it->second->setTarget(taskRelObject);
     56      it->second->process(dt);
     57      posR=posR+sideR*radius*1.5;
    4258
    43         for (it=members.begin(); it!= members.end(); it++ ){
    44                 radius=it->second->getNPCRadius();
    45                 posR=posR+sideR*radius*1.5;
    46                 it->second->setDestination(objectPos+taskRelPos+posR);
    47                 it->second->setDestinationMovement(Vector(0,0,0));
    48                 it->second->setTarget(taskRelObject);
    49                 it->second->process(dt);
    50                 posR=posR+sideR*radius*1.5;
     59      it++;
     60      if(it==members.end())break;
     61      radius=it->second->getNPCRadius();
     62      posL=posL+sideL*radius*1.5;
     63      it->second->setDestination(objectPos+taskRelPos+posL);
     64      it->second->setDestinationMovement(Vector(0,0,0));
     65      it->second->setTarget(taskRelObject);
     66      it->second->process(dt);
     67      posL=posL+sideL*radius*1.5;
     68    }
    5169
    52                 it++;
    53                 if(it==members.end())break;
    54                 radius=it->second->getNPCRadius();
    55                 posL=posL+sideL*radius*1.5;
    56                 it->second->setDestination(objectPos+taskRelPos+posL);
    57                 it->second->setDestinationMovement(Vector(0,0,0));
    58                 it->second->setTarget(taskRelObject);
    59                 it->second->process(dt);
    60                 posL=posL+sideL*radius*1.5;
    61         }
    62 
    63         //check time..
    64         taskMaxTime-=dt;
    65         if(taskMaxTime<0)taskComplete=true;
     70        //check time..
     71    taskMaxTime-=dt;
     72    if(taskMaxTime<0)taskComplete=true;
     73  }
    6674}
  • branches/cleanup/src/ai/swarm_gorel.cc

    r10376 r10615  
    4848        Vector correction=Vector(0,0,0);
    4949        Vector destination;
     50       
     51        WorldEntity* taskRelObject = NULL;
     52        if ( taskRelObjectName != "" )
     53          taskRelObject = dynamic_cast<WorldEntity*>(WorldEntity::objectList().getBaseObject( taskRelObjectName ));
    5054
    5155        if(taskRelObject!=NULL && taskMaxTime>0){
  • branches/cleanup/src/ai/swarm_module.h

    r10376 r10615  
    2424        inline void orderView(Vector taskView){this->taskView=taskView;}
    2525        inline void orderSpeed(float taskSpeed){this->taskSpeed=taskSpeed;}
    26         inline void orderRelObject(WorldEntity* taskRelObject){this->taskRelObject=taskRelObject;}
     26        inline void orderRelObject(WorldEntity* taskRelObject){if (taskRelObject) this->taskRelObjectName=taskRelObject->getName(); else taskRelObjectName = ""; }
    2727        inline void orderMaxTime(float taskMaxTime){this->taskMaxTime=taskMaxTime;}
    2828
     
    4444        Vector taskView;
    4545        float taskSpeed;
    46         WorldEntity* taskRelObject;
     46        std::string taskRelObjectName;
    4747        bool taskComplete;
    4848        float taskMaxTime;
  • branches/cleanup/src/ai/swarm_wait.cc

    r10555 r10615  
    1919void SwarmWait::process(float dt)
    2020{
    21         if(taskRelObject!=NULL){
    22                 Vector distVect=taskRelObject->getAbsCoor()-getSwarmPosition();
    23                 float distance=distVect.len();
    24                 if(distance<attackDistance+100)taskComplete=true;               //### change wakeup distance here
     21        if(taskRelObjectName!=""){
     22          WorldEntity* taskRelObject = dynamic_cast<WorldEntity*>(WorldEntity::objectList().getBaseObject( taskRelObjectName ));
     23          Vector distVect=taskRelObject->getAbsCoor()-getSwarmPosition();
     24          float distance=distVect.len();
     25          if(distance<attackDistance+100)taskComplete=true;             //### change wakeup distance here
    2526        }
    2627
Note: See TracChangeset for help on using the changeset viewer.