Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10275 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 17, 2007, 7:05:42 PM (18 years ago)
Author:
tfahrni
Message:

npc can shoot

Location:
branches/ai/src
Files:
8 edited

Legend:

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

    r10266 r10275  
    4848                        float maxTime=10;
    4949
     50
    5051                        //find new Position
    5152                        if(isPlayer){
     
    5354                                int zNorm=(position.z>targetPos.z)?1:-1;
    5455
    55                                 if((position.z-targetPos.z)*zNorm>80){  //go to start position
     56                                if((position.z-targetPos.z)*zNorm>60){  //go to start position
    5657                                        std::cout << "Go Start Position\n";
    5758                                        changeSwarmModule(it, new SwarmGoRel);
    58                                         newPosition=Vector(220,0,zNorm*60);
    59                                         speed=100;
     59                                        newPosition=Vector(180,0,zNorm*60);
     60                                        speed=80;
    6061                                }else if(position.x > targetPos.x+150){ //go to attack position
    6162                                        std::cout << "Go Attack Position\n";
    6263                                        changeSwarmModule(it, new SwarmGoRel);
    6364                                        newPosition=Vector(100,0,0);
    64                                         speed=60;
     65                                        speed=80;
    6566                                }else if(position.x > targetPos.x+90){  //go to attack mode
    6667                                        std::cout << "Go Attack Mode\n";
     
    7273                                        std::cout << "Go  Fallback Point\n";
    7374                                        changeSwarmModule(it, new SwarmGoRel);
    74                                         newPosition=Vector(0,0,zNorm*150);
    75                                         speed=60;
     75                                        newPosition=Vector(0,0,zNorm*100);
     76                                        speed=80;
    7677                                }
    7778                        }else{
  • branches/ai/src/ai/attack_module.cc

    r10266 r10275  
    2222#include "playable.h"
    2323#include "npcs/npc_test.h"
     24#include "weapons/weapon.h"
     25#include "projectiles/projectile.h"
    2426
    2527#include "shell_command.h"
     
    4648        tickCount=0;
    4749        randomFreq=40;
     50        fireTimeout=1;
    4851}
    4952
     
    5760        Vector npcCollision;
    5861        Vector playerCollision;
    59         bool autoRotate=true;
    6062
    6163        weight=1;
     
    8688        for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); ++it)
    8789        {
     90                if((*it)->isA(Weapon::staticClassID()) )continue;
     91                if((*it)->isA(Projectile::staticClassID()) )continue;
    8892                if(*it==npc)continue;
    8993
     
    143147
    144148        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        }
    145160}
    146161
  • branches/ai/src/ai/attack_module.h

    r10227 r10275  
    3636                int tickCount;
    3737                int randomFreq;
     38                float fireTimeout;
    3839                Vector randomVector;
    3940};
  • branches/ai/src/ai/movement_module.cc

    r10266 r10275  
    2222#include "playable.h"
    2323#include "npcs/npc_test.h"
     24#include "weapons/weapon.h"
     25#include "projectiles/projectile.h"
     26
    2427
    2528#include "shell_command.h"
     
    9093        for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); ++it)
    9194        {
     95                if((*it)->isA(Weapon::staticClassID()) )continue;
     96                if((*it)->isA(Projectile::staticClassID()) )continue;
    9297                if(*it==npc)continue;
    9398
     
    100105                npcCollision=npcCollision+tmpVector;
    101106        }
     107
    102108
    103109
  • branches/ai/src/ai/swarm_gorel.cc

    r10266 r10275  
    7676        }
    7777
    78         if(angleDeg(view,newView)>viewChangeMax){
     78        /*if(angleDeg(view,newView)>viewChangeMax){
    7979                std::cout << "alarm\n";
    80         }
     80        }*/
     81
    8182        speed=newSpeed;
    8283        view=newView;
     
    9394        if(!taskComplete){
    9495                //swarmPosition=this->getPosition();
    95                 if((destination-position).len()<5)taskComplete=true;
     96                if((destination-position).len()<10)taskComplete=true;
    9697        }
    9798}
  • branches/ai/src/world_entities/npcs/npc.cc

    r10268 r10275  
    2424#include "ai_engine.h"
    2525
     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"
    2634#include "debug.h"
    27 
    2835#include "loading/load_param.h"
    2936
     
    3239
    3340ObjectListDefinition(NPC);
     41CREATE_FACTORY(NPC);
     42
    3443
    3544NPC::NPC(const TiXmlElement* root)
     
    3847  this->registerObject(this, NPC::_objectList);
    3948
    40   this->toList(OM_GROUP_00);
     49  this->toList(OM_GROUP_01);
     50
     51  if( root != NULL)
     52          this->loadParams(root);
    4153
    4254  std::cout << "Team Number: " << teamNumber << "\n";
    4355  std::cout << "Swarm Number:" << swarmNumber << "\n";
    44   //aiModule=new MovementModule(this);
    45   //AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule);
     56
    4657  AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this);
    4758
    4859  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);
    49109
    50110}
     
    138198void NPC::tick(float dt)
    139199{
     200        //std::cout << "fire..\n";
    140201  this->weaponMan.tick(dt);
    141202  if (this->bFire)
  • branches/ai/src/world_entities/npcs/npc.h

    r10268 r10275  
    1717  virtual ~NPC ();
    1818
    19   virtual void loadParams(const TiXmlElement* root = NULL);
     19  virtual void loadParams(const TiXmlElement* root);
    2020
    2121
     
    2929  virtual void tick(float dt);
    3030  inline int getTeam()  { return teamNumber; }
     31  inline void fire(){ this->bFire=true;}
    3132
    32   inline void fire() { this->bFire = true; }
    3333
    3434
  • branches/ai/src/world_entities/npcs/npc_test.cc

    r10269 r10275  
    5252
    5353  // create the weapons and their manager
    54   this->addWeapon(wpLeft, 1, 0);
    55   this->addWeapon(wpRight,1 ,1);
    56 \
     54
     55
    5756  this->getWeaponManager().changeWeaponConfig(1);
    5857  Weapon* wpRight = new TestGun(0);
     
    6059  Weapon* wpLeft = new TestGun(1);
    6160  wpLeft->setName("testGun Left");
     61
     62  this->addWeapon(wpLeft, 1, 0);
     63  this->addWeapon(wpRight,1 ,1);
    6264
    6365  this->setHealthMax(100);
Note: See TracChangeset for help on using the changeset viewer.