Changeset 10615 in orxonox.OLD for branches/cleanup/src/ai/swarm_attack.cc
- Timestamp:
- Mar 30, 2007, 12:01:21 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/src/ai/swarm_attack.cc
r10376 r10615 30 30 void SwarmAttack::process(float dt) 31 31 { 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 33 44 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(); 38 49 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; 42 58 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 } 51 69 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 } 66 74 }
Note: See TracChangeset
for help on using the changeset viewer.