Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 13, 2007, 5:51:40 PM (17 years ago)
Author:
retolu
Message:

first shooting of the turret

File:
1 edited

Legend:

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

    r10688 r10689  
    139139        this->bFire = false;
    140140        this->playerVisible = false;
     141
     142       
    141143}
    142144
     
    151153
    152154
    153   Vector playerPos = this->myTarget->getAbsCoor();
     155  Vector playerPos = this->myTarget->getAbsCoor() + Vector(0, 12, 0);
    154156  Vector ds = playerPos - ( this->cannons->getAbsCoor() );
    155   if ( isActive && ds.len() <= range )
     157  if ( isActive && ds.len() <= range && playerVisible )
     158  {
    156159    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        }
     171  }
    157172  else
    158173    this->moveTowards( Vector(0, -1, 0), dt );
     
    212227}
    213228
    214 bool AdmTurret::isVisible(const WorldEntity myTarget)
    215 {
    216 return true;
    217 }
    218 
    219 float AdmTurret::aim(const WorldEntity Target)
    220 {
    221 return 0;
    222 }
    223 
    224229void AdmTurret::fire()
    225230{
    226         // Projectile* pj =  this->getProjectile();
    227         // if (pj == NULL) return;
    228 
    229         //pj->setOwner(this->getOwner());
    230         //pj->setParent(PNode::getNullParent());
    231         //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) );
    232         //pj->setAbsCoor(this->getEmissionPoint());
    233         //pj->setAbsDir(this->getAbsDir());
    234         //pj->activate();
    235231}
    236232
     
    245241       
    246242        this->cannons->toList( getOMListNumber() );
     243
     244        this->weapon = new BspWeapon();
     245        this->weapon->setParent( this->cannons );
     246        this->weapon->toList( getOMListNumber() );
     247        this->weapon->setAbsCoor( this->cannons->getAbsCoor() );
     248        this->weapon->setAbsDir( this->weapon->getAbsDir() * Quaternion( PI, Vector(0, 1, 0) ) );
    247249}
    248250
     
    257259        this->sensor->toList( getOMListNumber() );
    258260}
    259 
    260261
    261262void AdmTurret::moveTowards( Vector targetDir, float dt )
     
    336337  Vector dir = this->myTarget->getAbsCoor() - pos;
    337338
     339
    338340  this->playerVisible = true;
    339341  for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
Note: See TracChangeset for help on using the changeset viewer.