Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6637 in orxonox.OLD


Ignore:
Timestamp:
Jan 21, 2006, 1:27:29 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the SpaceShipControl branche back to the trunk

merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/spaceshipcontrol . -r6482:HEAD

minor conflicts, and added file hover.cc/h to the Makefile.

Location:
trunk/src
Files:
12 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r6634 r6637  
    178178  CL_SPAWNING_POINT             =    0x0000020c,
    179179  CL_MD2_CREATURE               =    0x0000020d,
     180  CL_HOVER                      =    0x0000020e,
    180181
    181182  CL_TURRET_POWER_UP            =    0x00000211,
  • trunk/src/world_entities/Makefile.am

    r6634 r6637  
    5151                  world_entities/space_ships/space_ship.cc \
    5252                  world_entities/space_ships/helicopter.cc \
     53                  world_entities/space_ships/hover.cc \
    5354                  world_entities/creatures/md2_creature.cc \
    5455                  \
     
    102103                 world_entities/space_ships/space_ship.h \
    103104                 world_entities/space_ships/helicopter.h \
     105                 world_entities/space_ships/hover.h \
    104106                 world_entities/creatures/md2_creature.h \
    105107                 \
  • trunk/src/world_entities/projectiles/guided_missile.cc

    r6627 r6637  
    4343  this->setMaxEnergy(10);
    4444  this->lifeSpan = 10.0;
    45   this->agility = 500;
     45  this->agility = 5;
    4646  this->maxVelocity = 75;
    4747
  • trunk/src/world_entities/space_ships/helicopter.cc

    r6512 r6637  
    117117  bFire = false;
    118118  xMouse = yMouse = 0;
    119   mouseSensitivity = 0.001;
    120   rotorspeed = 1;
    121   tailrotorspeed = 0;
    122 
    123   cycle = 0.0;
    124 
    125 
    126   travelSpeed = 15.0;
     119  mouseSensitivity = 0.05;
     120  //rotorspeed = 1;
     121  //tailrotorspeed = 0;
     122
     123  //cycle = 0.0;
     124
     125
     126  //travelSpeed = 15.0;
    127127  this->velocity = Vector(0.0,0.0,0.0);
    128128  this->velocityDir = Vector(1.0,0.0,0.0);
     
    134134
    135135  //add events to the eventlist
    136   registerEvent(SDLK_w);
    137   registerEvent(SDLK_s);
    138   registerEvent(SDLK_a);
    139   registerEvent(SDLK_d);
    140   registerEvent(SDLK_q);
     136  registerEvent(KeyMapper::PEV_UP);
     137  registerEvent(KeyMapper::PEV_DOWN);
     138  registerEvent(KeyMapper::PEV_LEFT);
     139  registerEvent(KeyMapper::PEV_RIGHT);
     140  //registerEvent(SDLK_q);
    141141  registerEvent(SDLK_e);
    142142  registerEvent(SDLK_c);
     
    144144  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
    145145  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
    146   registerEvent(SDLK_PAGEUP);
    147   registerEvent(SDLK_PAGEDOWN);
     146  //registerEvent(SDLK_PAGEUP);
     147  //registerEvent(SDLK_PAGEDOWN);
    148148  registerEvent(EV_MOUSE_MOTION);
    149149
     
    249249void Helicopter::tick (float time)
    250250{
     251  /*
    251252  tailrotorspeed += xMouse/20;
    252253  if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07;
     
    256257  else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001;
    257258  if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0;
    258 
     259  */
     260 
    259261  // spaceship controlled movement
    260262  this->calculateVelocity(time);
    261263
    262   Vector move = (velocity);
     264  Vector move = (velocity)*time;
    263265
    264266  // this is the air friction (necessary for a smooth control)
    265267  if(velocity.len() != 0) velocity -= velocity*0.1;
     268 
     269  //travelSpeed = velocity.len();
    266270
    267271  //physics: Gravity
    268   this->shiftCoor(Vector(0,-1,0));
     272  /*this->shiftCoor(Vector(0,-1,0));
    269273
    270274  this->shiftCoor(getAbsDirY()*rotorspeed);
    271 
     275  */
     276 
     277  /*
    272278  //hoover effect
    273279  cycle += time;
    274280  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     281  */
    275282
    276283  //readjust
     
    281288
    282289  this->shiftCoor (move);
    283   this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
     290  //this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
    284291
    285292  this->getWeaponManager()->tick(time);
     
    295302{
    296303  Vector accel(0.0, 0.0, 0.0);
    297   Vector rot(0.0, 0.0, 0.0);
    298   float rotVal = 0.0;
     304  float rotValX = 0.0;
     305  float rotValZ = 0.0;
    299306  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    300307  /* calculate the direction in which the craft is heading  */
     
    304311     //this->shiftCoor(this->getAbsDirX());
    305312     //accel -= this->getAbsDirY();
    306      rot += Vector (0,0,1);
    307      rotVal -= time/5;
     313     
     314     accel += Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z);
     315     if((this->getAbsDirX()).y >= -0.1) rotValZ -= time;
    308316   }
    309317   else
    310318   {
    311        if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/8, Vector(0,0,1)));
     319       if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time, Vector(0,0,1)));
    312320   }
    313321
     
    316324     //this->shiftCoor((this->getAbsDirX())*-1);
    317325     //accel -= this->getAbsDirY();
    318      rot += Vector (0,0,1);
    319      rotVal += time/5;
     326     
     327     accel -= Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z);
     328     rotValZ += time;
    320329   }
    321330   else
    322331   {
    323          if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time/8, Vector(0,0,1)));
     332         if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    324333   }
    325334
     
    329338    //accel -= this->getAbsDirY();
    330339    //velocityDir.normalize();
    331     rot += Vector(1,0,0);
    332     rotVal -= time/5;
     340   
     341    accel -= Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z);
     342    rotValX -= time;
    333343  }
    334344  else
    335345   {
    336          if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0)));
     346         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time, Vector(1,0,0)));
    337347   }
    338348
     
    340350  {
    341351    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    342     accel += this->getAbsDirY();
     352    //accel += this->getAbsDirY();
    343353    //velocityDir.normalize();
    344     rot += Vector(1,0,0);
    345     rotVal += time/5;
     354   
     355    accel += Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z);
     356    rotValX += time;
    346357  }
    347358  else
    348359   {
    349          if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time/5, Vector(1,0,0)));
     360         if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time, Vector(1,0,0)));
    350361   }
    351362
     
    371382    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
    372383
    373     rotorspeed += 0.05;
    374     if (rotorspeed >= 2) rotorspeed = 2;
     384    accel += this->getAbsDirY();
     385    //rotorspeed += 0.05;
     386    //if (rotorspeed >= 2) rotorspeed = 2;
    375387    //velocityDir.normalize();
    376388    //rot += Vector(0,0,1);
     
    379391  else
    380392  {
    381     if(rotorspeed >= 1.05) rotorspeed -= 0.05;
     393    //if(rotorspeed >= 1.05) rotorspeed -= 0.05;
    382394  }
    383395
     
    386398    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    387399
    388     rotorspeed -= 0.05;
    389     if (rotorspeed <= 0) rotorspeed = 0;
     400    accel -= this->getAbsDirY();
     401    //rotorspeed -= 0.05;
     402    //if (rotorspeed <= 0) rotorspeed = 0;
    390403    //velocityDir.normalize();
    391404    //rot += Vector(0,0,1);
     
    394407  else
    395408  {
    396     if(rotorspeed <= 0.05) rotorspeed += 0.05;
    397   }
    398 
    399   //velocity += accel;
    400   rot.normalize();
    401   this->shiftDir(Quaternion(rotVal, rot));
     409    //if(rotorspeed <= 0.05) rotorspeed += 0.05;
     410  }
     411
     412  velocity += accel*3;
     413  if((this->getAbsDirX()).y <= 0.3 && (this->getAbsDirX()).y >= -0.3) this->shiftDir(Quaternion(rotValZ, Vector(0,0,1)));
     414  if((this->getAbsDirZ()).y <= 0.3 && (this->getAbsDirZ()).y >= -0.3) this->shiftDir(Quaternion(rotValX, Vector(1,0,0)));
    402415}
    403416
     
    429442
    430443
    431   if( event.type == SDLK_a)
     444  if( event.type == KeyMapper::PEV_LEFT)
    432445      this->bLeft = event.bPressed;
    433   else if( event.type == SDLK_d)
     446  else if( event.type == KeyMapper::PEV_RIGHT)
    434447      this->bRight = event.bPressed;
    435448  else if( event.type == KeyMapper::PEV_FIRE1)
     
    443456  else if( event.type == SDLK_c)
    444457    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
    445   else if( event.type == SDLK_w)
     458  else if( event.type == KeyMapper::PEV_UP)
    446459    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
    447   else if( event.type == SDLK_s)
     460  else if( event.type == KeyMapper::PEV_DOWN)
    448461    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
    449462  else if( event.type == EV_MOUSE_MOTION)
     
    452465    this->yMouse = event.yRel*mouseSensitivity;
    453466
    454     //this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     467    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))/*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*/);
    455468  }
    456469}
  • trunk/src/world_entities/space_ships/helicopter.h

    r6512 r6637  
    5757    float                 xMouse;             //!< mouse moved in x-Direction
    5858    float                 yMouse;             //!< mouse moved in y-Direction
     59    int                   yInvert;
    5960    float                 mouseSensitivity;   //!< the mouse sensitivity
    60     float                 cycle;              //!< hovercycle
     61    //float                 cycle;              //!< hovercycle
    6162
    6263    Vector                velocity;           //!< the velocity of the player.
     
    6465    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6566    float                 acceleration;       //!< the acceleration of the player.
    66     float                 rotorspeed;         //!< the speed of the rotor.
    67     float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
     67    //float                 rotorspeed;         //!< the speed of the rotor.
     68    //float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
    6869
    6970    float                 airViscosity;
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6634 r6637  
    132132  bFire = false;
    133133  xMouse = yMouse = 0;
     134  yInvert = 1;
    134135  mouseSensitivity = 0.001;
    135   airViscosity = 1.0;
    136   cycle = 0.0;
     136  airViscosity = 0.01;
     137  controlVelocityX = 25;
     138  controlVelocityY = 150;
     139  shipInertia = 0.5             ;
     140//  cycle = 0.0;
    137141
    138142  this->setMaxEnergy(100);
    139143  this->setEnergy(80);
    140144
    141   travelSpeed = 15.0;
    142   this->velocity = Vector(0.0,0.0,0.0);
     145  travelSpeed = 40.0;
     146  acceleration = 3;
     147  this->velocity = this->getAbsDirX()*travelSpeed;
    143148  this->mouseDir = this->getAbsDir();
     149  this->pitchDir = this->getAbsDir();
    144150
    145151//   GLGuiButton* button = new GLGuiPushButton();
     
    155161
    156162  //add events to the eventlist
    157   registerEvent(SDLK_w);
    158   registerEvent(SDLK_s);
    159   registerEvent(SDLK_a);
    160   registerEvent(SDLK_d);
    161   registerEvent(SDLK_q);
    162   registerEvent(SDLK_e);
     163  registerEvent(KeyMapper::PEV_UP);
     164  registerEvent(KeyMapper::PEV_DOWN);
     165  registerEvent(KeyMapper::PEV_LEFT);
     166  registerEvent(KeyMapper::PEV_RIGHT);
     167  //registerEvent(SDLK_q);
     168  //registerEvent(SDLK_e);
    163169  registerEvent(KeyMapper::PEV_FIRE1);
    164170  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
    165171  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
    166   registerEvent(SDLK_PAGEUP);
    167   registerEvent(SDLK_PAGEDOWN);
     172  //registerEvent(SDLK_PAGEUP);
     173  //registerEvent(SDLK_PAGEDOWN);
    168174  registerEvent(EV_MOUSE_MOTION);
    169175
     
    279285  this->weaponAction();
    280286
     287  if( xMouse != 0 || yMouse != 0)
     288   {
     289    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     290    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     291    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
     292    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
     293   
     294    pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
     295   
     296    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
     297    xMouse = yMouse = 0;
     298   }
     299
     300
    281301//   if( this != State::getPlayer()->getControllable())
    282302//     return;
     
    285305  this->calculateVelocity(time);
    286306
    287   Vector move = (velocity)*time;
    288 
     307  Vector move = velocity*time;
     308 
    289309  //orient the velocity in the direction of the spaceship.
    290310  travelSpeed = velocity.len();
     
    293313
    294314  //orient the spaceship in direction of the mouse
    295    rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, fabsf(time)*3.0);
     315   rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, fabsf(time)*shipInertia);
    296316   if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
    297317    this->setAbsDir( rotQuat);
     
    299319
    300320  // this is the air friction (necessary for a smooth control)
    301   if(velocity.len() != 0) velocity -= velocity*0.01;
    302 
     321  if(travelSpeed >= 120) velocity -= velocity.getNormalized()*travelSpeed*travelSpeed*0.0001;
     322  else if (travelSpeed <= 80) velocity -= velocity.getNormalized()*travelSpeed*0.001;
     323 
     324  //other physics (gravity)
     325  if(travelSpeed < 120)
     326  move += Vector(0,-1,0)*60*time + Vector(0,1,0)*travelSpeed/2*time;
     327   
    303328  //hoover effect
    304329  //cycle += time;
     
    306331
    307332  //readjust
    308 
    309   /*
    310     In the game "Yager" the spaceship gets readjusted when the player moves the mouse.
    311     I (bknecht) go and check it out how they do it, we could probably use this also in Orxonox.
    312   */
    313   //if (xMouse != 0 && yMouse != 0)
    314 
    315333  //if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
    316334  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
     
    318336  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    319337
    320   this->shiftCoor (move);
     338  this->shiftCoor(move);
    321339
    322340
     
    337355  /* calculate the direction in which the craft is heading  */
    338356
    339   Plane plane(Vector(0,1,0), Vector(0,0,0));
     357  //Plane plane(Vector(0,1,0), Vector(0,0,0));
    340358
    341359  if( this->bUp )
    342360   {
    343361     //this->shiftCoor(this->getAbsDirX());
    344       accel += (this->getAbsDirX())*2;
    345 
    346       /* Heli-Steuerung
    347          accel += (this->getAbsDirX()*2;
    348          if(
    349       */
     362      //accel += (this->getAbsDirX())*2;
     363      accel += (this->getAbsDirX())*acceleration;
     364
    350365   }
    351366
     
    353368   {
    354369     //this->shiftCoor((this->getAbsDirX())*-1);
    355      accel -= (this->getAbsDirX())*2;
     370     //accel -= (this->getAbsDirX())*2;
     371     accel -= (this->getAbsDirX())*0.5*acceleration;
    356372   }
    357373
     
    377393  if( this->bRollL /* > -this->getRelCoor().z*2*/)
    378394  {
    379     mouseDir *= Quaternion(-time, Vector(1,0,0));
     395    mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    380396//    accel -= rightDirection;
    381397    //velocityDir.normalize();
     
    385401  if( this->bRollR /* > this->getRelCoor().z*2*/)
    386402  {
    387     mouseDir *= Quaternion(time, Vector(1,0,0));
     403    mouseDir *= Quaternion(time*2, Vector(1,0,0));
    388404
    389405    //    accel += rightDirection;
     
    432448void SpaceShip::process(const Event &event)
    433449{
    434 
    435 
    436   if( event.type == SDLK_a)
     450  if( event.type == KeyMapper::PEV_LEFT)
    437451      this->bRollL = event.bPressed;
    438   else if( event.type == SDLK_d)
     452  else if( event.type == KeyMapper::PEV_RIGHT)
    439453      this->bRollR = event.bPressed;
    440454  else if( event.type == KeyMapper::PEV_FIRE1)
     
    446460  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
    447461    this->previousWeaponConfig();
    448   else if( event.type == SDLK_w)
     462  else if( event.type == KeyMapper::PEV_UP)
    449463    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
    450   else if( event.type == SDLK_s)
     464  else if( event.type == KeyMapper::PEV_DOWN)
    451465    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
    452466  else if( event.type == EV_MOUSE_MOTION)
    453467  {
    454     this->xMouse = event.xRel;
    455     this->yMouse = event.yRel;
    456     mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    457    // if( xMouse*xMouse + yMouse*yMouse < 0.9)
    458      //this->setAbsDir(mouseDir);
     468    this->xMouse += event.xRel;
     469    this->yMouse += event.yRel;
    459470  }
    460471}
  • trunk/src/world_entities/space_ships/space_ship.h

    r6634 r6637  
    6565    float                 yMouse;             //!< mouse moved in y-Direction
    6666    float                 mouseSensitivity;   //!< the mouse sensitivity
    67     float                 cycle;              //!< hovercycle
     67    int                   yInvert;
     68    int                   controlVelocityX;
     69    int                   controlVelocityY;
     70//    float                 cycle;              //!< hovercycle
    6871
    6972    Vector                velocity;           //!< the velocity of the player.
    7073    Quaternion            mouseDir;           //!< the direction where the player wants to fly
     74    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
    7175    Quaternion            rotQuat;
     76    Quaternion            pitchDir;
    7277    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    7378    float                 acceleration;       //!< the acceleration of the player.
  • trunk/src/world_entities/weapons/aim.cc

    r6512 r6637  
    7373  this->source = NULL;
    7474
     75  this->range = 0;
     76  this->angle = 0;
    7577  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7678  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    101103}
    102104
    103 void Aim::searchTarget(float range)
     105void Aim::searchTarget()
    104106{
    105107  std::list<WorldEntity*>::iterator entity;
    106 
     108  Vector diffVec(0.0, 0.0, 0.0);
     109  diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() );
     110
     111//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
     112  if( this == PNode::getNullParent() || diffVec.len() > range  || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    107113  for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
    108114       entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
    109115       entity ++)
    110116  {
    111     if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range)
     117    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
     118
     119    if ( diffVec.len() < range  &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)
    112120    {
    113121      if (this->getParent() != (*entity))
     
    119127    }
    120128  }
    121 }
    122 
     129//if no target found:
     130  this->setParent(PNode::getNullParent());
     131}
    123132
    124133
     
    155164
    156165
    157   if (this->source->getAbsCoor().x > this->getAbsCoor().x )
    158     this->searchTarget(1000);
     166//  if (this->source->getAbsCoor().x > this->getAbsCoor().x )
     167     this->searchTarget();
    159168//   float z = 0.0f;
    160169//   glReadPixels ((int)this->getAbsCoor2D().x,
  • trunk/src/world_entities/weapons/aim.h

    r6512 r6637  
    3838  inline PNode* getTarget(PNode* target) { return this->getParent(); };
    3939
    40   void searchTarget(float range);
     40  void searchTarget();
     41
     42  void setRange(float range){this->range = range;};
     43  void setAngle(float angle){this->angle = angle;};
    4144
    4245  void setSize(float size);
     
    5356   tAnimation<Aim>* anim;
    5457
     58   float            range;                //!<
     59   float            angle;                //!<
     60
    5561   PNode*           source;               //!< Where this Shot has come from.
    5662
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r6512 r6637  
    9898  this->target = new Aim(this);
    9999  this->target->setVisibility(false);
     100  this->target->setRange(100);
     101  this->target->setAngle(M_PI);
    100102}
    101103
     
    146148  pj->setAbsDir(this->getAbsDir());
    147149  pj->activate();
    148   this->target->searchTarget(100);
     150  this->target->searchTarget();
    149151}
    150152
  • trunk/src/world_entities/weapons/targeting_turret.cc

    r6512 r6637  
    9292  this->target = new Aim(this);
    9393  this->target->setVisibility(false);
    94 
     94  this->target->setRange(100);
     95  this->target->setAngle(M_PI_4/2);
     96  this->lockedTime = 0;
     97  this->neededLockTime = 2;
     98  this->lockedTarget->setParent(PNode::getNullParent());
    9599  this->loadModel("models/guns/turret2.obj");
    96100
     
    119123void TargetingTurret::tick(float dt)
    120124{
     125  if( lockedTime >= neededLockTime )
     126   {
     127    lockedTarget = this->target->getParent();
     128    lockedTime = 0;
     129   }
    121130
    122131  this->target->tick(dt);
     132
     133  if(this->target->getParent() == PNode::getNullParent())
     134   lockedTime = 0;
     135  else
     136   lockedTime += dt;
     137
    123138}
    124139
     
    137152  pj->setAbsDir(this->getAbsDir());
    138153  pj->activate();
    139   this->target->searchTarget(100);
     154  this->target->searchTarget();
    140155}
    141156
  • trunk/src/world_entities/weapons/targeting_turret.h

    r6512 r6637  
    3232
    3333  private:
    34     Aim*          target;
    35   };
     34    Aim*           target;
     35    PNode*         lockedTarget;
     36    float          lockedTime;
     37    float          neededLockTime;
     38  };
    3639
    3740#endif /* _TARGETING_TURRET_H */
Note: See TracChangeset for help on using the changeset viewer.