Changeset 10275 in orxonox.OLD for branches/ai
- Timestamp:
- Jan 17, 2007, 7:05:42 PM (18 years ago)
- Location:
- branches/ai/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/ai/ai_team.cc
r10266 r10275 48 48 float maxTime=10; 49 49 50 50 51 //find new Position 51 52 if(isPlayer){ … … 53 54 int zNorm=(position.z>targetPos.z)?1:-1; 54 55 55 if((position.z-targetPos.z)*zNorm> 80){ //go to start position56 if((position.z-targetPos.z)*zNorm>60){ //go to start position 56 57 std::cout << "Go Start Position\n"; 57 58 changeSwarmModule(it, new SwarmGoRel); 58 newPosition=Vector( 220,0,zNorm*60);59 speed= 100;59 newPosition=Vector(180,0,zNorm*60); 60 speed=80; 60 61 }else if(position.x > targetPos.x+150){ //go to attack position 61 62 std::cout << "Go Attack Position\n"; 62 63 changeSwarmModule(it, new SwarmGoRel); 63 64 newPosition=Vector(100,0,0); 64 speed= 60;65 speed=80; 65 66 }else if(position.x > targetPos.x+90){ //go to attack mode 66 67 std::cout << "Go Attack Mode\n"; … … 72 73 std::cout << "Go Fallback Point\n"; 73 74 changeSwarmModule(it, new SwarmGoRel); 74 newPosition=Vector(0,0,zNorm*1 50);75 speed= 60;75 newPosition=Vector(0,0,zNorm*100); 76 speed=80; 76 77 } 77 78 }else{ -
branches/ai/src/ai/attack_module.cc
r10266 r10275 22 22 #include "playable.h" 23 23 #include "npcs/npc_test.h" 24 #include "weapons/weapon.h" 25 #include "projectiles/projectile.h" 24 26 25 27 #include "shell_command.h" … … 46 48 tickCount=0; 47 49 randomFreq=40; 50 fireTimeout=1; 48 51 } 49 52 … … 57 60 Vector npcCollision; 58 61 Vector playerCollision; 59 bool autoRotate=true;60 62 61 63 weight=1; … … 86 88 for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); ++it) 87 89 { 90 if((*it)->isA(Weapon::staticClassID()) )continue; 91 if((*it)->isA(Projectile::staticClassID()) )continue; 88 92 if(*it==npc)continue; 89 93 … … 143 147 144 148 npc->setAbsDirSoft( Quaternion( view, Vector(0,1,0)),1); 149 150 151 if(npc->isA(NPC::staticClassID()) ){ 152 fireTimeout-=dt; 153 if(fireTimeout<=0){ 154 fireTimeout=1; 155 //std::cout << "Fiiiiirrreee!\n"; 156 NPC* npc2 = static_cast<NPC*>(npc); 157 npc2->fire(); 158 } 159 } 145 160 } 146 161 -
branches/ai/src/ai/attack_module.h
r10227 r10275 36 36 int tickCount; 37 37 int randomFreq; 38 float fireTimeout; 38 39 Vector randomVector; 39 40 }; -
branches/ai/src/ai/movement_module.cc
r10266 r10275 22 22 #include "playable.h" 23 23 #include "npcs/npc_test.h" 24 #include "weapons/weapon.h" 25 #include "projectiles/projectile.h" 26 24 27 25 28 #include "shell_command.h" … … 90 93 for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); ++it) 91 94 { 95 if((*it)->isA(Weapon::staticClassID()) )continue; 96 if((*it)->isA(Projectile::staticClassID()) )continue; 92 97 if(*it==npc)continue; 93 98 … … 100 105 npcCollision=npcCollision+tmpVector; 101 106 } 107 102 108 103 109 -
branches/ai/src/ai/swarm_gorel.cc
r10266 r10275 76 76 } 77 77 78 if(angleDeg(view,newView)>viewChangeMax){78 /*if(angleDeg(view,newView)>viewChangeMax){ 79 79 std::cout << "alarm\n"; 80 } 80 }*/ 81 81 82 speed=newSpeed; 82 83 view=newView; … … 93 94 if(!taskComplete){ 94 95 //swarmPosition=this->getPosition(); 95 if((destination-position).len()< 5)taskComplete=true;96 if((destination-position).len()<10)taskComplete=true; 96 97 } 97 98 } -
branches/ai/src/world_entities/npcs/npc.cc
r10268 r10275 24 24 #include "ai_engine.h" 25 25 26 #include "player.h" 27 #include "playable.h" 28 29 #include "weapons/test_gun.h" 30 #include "weapons/turret.h" 31 #include "weapons/cannon.h" 32 33 #include "loading/factory.h" 26 34 #include "debug.h" 27 28 35 #include "loading/load_param.h" 29 36 … … 32 39 33 40 ObjectListDefinition(NPC); 41 CREATE_FACTORY(NPC); 42 34 43 35 44 NPC::NPC(const TiXmlElement* root) … … 38 47 this->registerObject(this, NPC::_objectList); 39 48 40 this->toList(OM_GROUP_00); 49 this->toList(OM_GROUP_01); 50 51 if( root != NULL) 52 this->loadParams(root); 41 53 42 54 std::cout << "Team Number: " << teamNumber << "\n"; 43 55 std::cout << "Swarm Number:" << swarmNumber << "\n"; 44 //aiModule=new MovementModule(this); 45 //AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule); 56 46 57 AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this); 47 58 48 59 this->bFire = false; 60 61 62 // create the weapons and their manager 63 64 65 this->getWeaponManager().changeWeaponConfig(1); 66 Weapon* wpRight = new TestGun(0); 67 wpRight->setName("testGun Right"); 68 Weapon* wpLeft = new TestGun(1); 69 wpLeft->setName("testGun Left"); 70 71 wpRight->toList( this->getOMListNumber()); 72 wpLeft->toList( this->getOMListNumber()); 73 74 75 this->addWeapon(wpLeft, 1, 0); 76 this->addWeapon(wpRight,1 ,1); 77 78 wpLeft->increaseEnergy( 100); 79 wpRight->increaseEnergy( 100); 80 81 this->setHealthMax(100); 82 this->setHealth(80); 83 84 this->getWeaponManager().setSlotCount(7); 85 86 this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0)); 87 this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 88 89 this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0)); 90 this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 91 92 this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5)); 93 this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 94 95 this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5)); 96 this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 97 98 this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5)); 99 this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 100 101 this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5)); 102 this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 103 104 this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0)); 105 this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 106 107 this->getWeaponManager().getFixedTarget()->setParent(this); 108 this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0); 49 109 50 110 } … … 138 198 void NPC::tick(float dt) 139 199 { 200 //std::cout << "fire..\n"; 140 201 this->weaponMan.tick(dt); 141 202 if (this->bFire) -
branches/ai/src/world_entities/npcs/npc.h
r10268 r10275 17 17 virtual ~NPC (); 18 18 19 virtual void loadParams(const TiXmlElement* root = NULL);19 virtual void loadParams(const TiXmlElement* root); 20 20 21 21 … … 29 29 virtual void tick(float dt); 30 30 inline int getTeam() { return teamNumber; } 31 inline void fire(){ this->bFire=true;} 31 32 32 inline void fire() { this->bFire = true; }33 33 34 34 -
branches/ai/src/world_entities/npcs/npc_test.cc
r10269 r10275 52 52 53 53 // create the weapons and their manager 54 this->addWeapon(wpLeft, 1, 0); 55 this->addWeapon(wpRight,1 ,1); 56 \ 54 55 57 56 this->getWeaponManager().changeWeaponConfig(1); 58 57 Weapon* wpRight = new TestGun(0); … … 60 59 Weapon* wpLeft = new TestGun(1); 61 60 wpLeft->setName("testGun Left"); 61 62 this->addWeapon(wpLeft, 1, 0); 63 this->addWeapon(wpRight,1 ,1); 62 64 63 65 this->setHealthMax(100);
Note: See TracChangeset
for help on using the changeset viewer.