Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10694 in orxonox.OLD for branches/adm/src/world_entities/npcs


Ignore:
Timestamp:
Jun 14, 2007, 3:50:14 PM (18 years ago)
Author:
retolu
Message:

adm working

Location:
branches/adm/src/world_entities/npcs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/adm/src/world_entities/npcs/adm_turret.cc

    r10690 r10694  
    7676                LoadParamXML(root, "Sensor", this, AdmTurret, addSensor)
    7777                        .describe("add sensor to ADM");
     78                LoadParamXML(root, "Weapon", this, AdmTurret, addWeapon)
     79                        .describe("add weapon to ADM");
    7880
    7981        }
     
    137139        this->range = 400;
    138140        this->isCeil = false;
    139         this->bFire = false;
    140141        this->playerVisible = false;
    141142
     
    146147{
    147148  WorldEntity::tick(dt);
    148  
     149  this->weapon->fire(false);
    149150  this->updatePlayerVisible();
    150151
     
    158159  {
    159160    this->moveTowards( ds,  dt);
    160 
    161   //if target within +/- 2.5 degrees of aim -> fire
    162   Vector dv1 = ds;
    163   dv1.normalize();
    164   Vector dv2 = this->cannons->getAbsDir().apply( Vector(-1, 0, 0));
    165   dv2.normalize();
    166   float angle = dv1.dot(dv2);
    167   if (angle > 0.999)
    168         {
    169         this->fire();
    170         }
     161   
     162    //if target within +/- 2.5 degrees of aim -> fire
     163    Vector dv1 = ds;
     164    dv1.normalize();
     165    Vector dv2 = this->cannons->getAbsDir().apply( Vector(-1, 0, 0));
     166    dv2.normalize();
     167    float angle = dv1.dot(dv2);
     168    if (angle > 0.999)
     169          {
     170     this->weapon->fire(true);
     171          }
    171172  }
    172173  else
     
    178179  WorldEntity::draw();
    179180
    180 
     181#if 0
    181182  glMatrixMode(GL_MODELVIEW);
    182183  glPushMatrix();
     
    212213  glPopAttrib();
    213214  glPopMatrix();
    214  
     215#endif
    215216}
    216217
     
    227228}
    228229
    229 void AdmTurret::fire()
    230 {
    231 }
    232 
    233230void AdmTurret::addCannons( const TiXmlElement * root )
    234231{
    235         this->cannons = new WorldEntity();
     232  this->cannons = new WorldEntity();
    236233        this->cannons->setParent(this);
    237234        this->cannons->loadParams( root );
     
    242239        this->cannons->toList( getOMListNumber() );
    243240
     241
     242}
     243
     244void AdmTurret::addWeapon( const TiXmlElement * root )
     245{
    244246        this->weapon = new BspWeapon();
     247        this->weapon->setParent( this->cannons );
    245248        this->weapon->loadParams(root);
    246         this->weapon->setParent( this->cannons );
    247249        this->weapon->toList( getOMListNumber() );
    248         this->weapon->setAbsCoor( this->cannons->getAbsCoor() );
     250        //this->weapon->setAbsCoor( this->cannons->getAbsCoor() );
    249251        this->weapon->setAbsDir( this->weapon->getAbsDir() * Quaternion( PI, Vector(0, 1, 0) ) );
    250252}
     
    252254void AdmTurret::addSensor( const TiXmlElement * root )
    253255{
    254         this->sensor = new WorldEntity();
     256  this->sensor = new WorldEntity();
    255257        this->sensor->setParent(this);
    256258        this->sensor->loadParams( root );
     
    285287   if ( isCeil )
    286288   {
    287      printf( "ceil\n" );
    288289     baseRot = Quaternion( PI, Vector( 1, 0, 0 ) );
    289290   }
  • branches/adm/src/world_entities/npcs/adm_turret.h

    r10689 r10694  
    3737                   WorldEntity* sensor;
    3838                   WorldEntity* myTarget;
    39                    void fire();
    4039
    4140                   void addCannons(const TiXmlElement* root);
    4241                   void addSensor(const TiXmlElement* root);
     42                   void addWeapon(const TiXmlElement* root);
    4343
    4444                   void moveTowards( Vector targetDir, float dt );
     
    5353                   void setType( const std::string& type );
    5454                   
    55                    bool bFire;
    5655                   bool playerVisible;
    5756                   void updatePlayerVisible();
     
    6160
    6261#endif
     62
Note: See TracChangeset for help on using the changeset viewer.