Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10710 in orxonox.OLD


Ignore:
Timestamp:
Jun 17, 2007, 2:25:20 PM (17 years ago)
Author:
rennerc
Message:

player cannot shoot throu walls
per default worldentities cannot be killed
weapon correct again

Location:
branches/presentation/src/world_entities
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/npcs/npc.cc

    r10698 r10710  
    440440
    441441// HACK just to make sure they explode as nice as possible :)
    442 void NPC::hit( float damage, WorldEntity* killer)
     442/*void NPC::hit( float damage, WorldEntity* killer)
    443443{
    444444  this->destroy( killer);
    445445  this->setDamage(killer->getDamage());
    446 }
     446}*/
  • branches/presentation/src/world_entities/npcs/npc.h

    r10546 r10710  
    3737  void destroy( WorldEntity* killer );
    3838
    39   void hit( float damage, WorldEntity* killer);
     39  //void hit( float damage, WorldEntity* killer);
    4040
    4141  inline void destroyThis() { this->destroy(NULL);};
  • branches/presentation/src/world_entities/weapons/bsp_weapon.cc

    r10709 r10710  
    133133        //gunFirExpl.explode(gunFire2,Vector(2,2,2));
    134134
    135   for ( std::list<MuzzleFlash*>::iterator it = gunFire.begin(); it!=gunFire.end(); it++)
    136         {
    137     (*it)->explode( 0.2 );
    138         }
    139 
    140         std::list<WorldEntity*>::iterator entityIterator;
    141         // for all bsp managers check all entities
    142         Vector pos = this->getAbsCoor();
    143         Vector dir = pos + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*range;
    144        
    145        
    146         float shortestDist = range;
    147         for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
    148                 bspIterator != BspEntity::objectList().end();
    149                 bspIterator++) {
    150                 float res = (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollisionRay( pos, dir, dir.len() + 1 );
    151        
    152                 if ( res < shortestDist )
    153                         shortestDist = res;
    154         }
    155 
    156         WorldEntity* target = aimingSystem->getNearestTarget();
    157         aimingSystem->flushList();
    158        
    159         if ( target != NULL )
    160         {
    161                 if (!alwaysHits){
    162                         float r = rand();
    163                         r = r/RAND_MAX;
    164                         float res = (target->getAbsCoor() - this->getAbsCoor()).len();
    165                         float p = 1 - res*res/range/range;
    166                         if (r < p ){
    167                                 printf( "HIT %s\n", target->getClassName().c_str() );
    168                                 target->hit( this->damage, this );
    169                         }
    170                         else
    171                                 printf( "MISHIT %s\n", target->getClassName().c_str() );
    172                        
    173                 }
    174                 else
    175                 {
    176                         printf( "HIT %s\n", target->getClassName().c_str() );
    177                         target->hit( this->damage, this );
    178                 }
    179         }
    180 
    181        
    182        
     135for ( std::list<MuzzleFlash*>::iterator it = gunFire.begin(); it!=gunFire.end(); it++)
     136{
     137  (*it)->explode( 0.2 );
     138}
     139
     140std::list<WorldEntity*>::iterator entityIterator;
     141// for all bsp managers check all entities
     142Vector pos = this->getAbsCoor();
     143Vector dir = pos + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*range;
     144
     145
     146float shortestDist = range;
     147for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
     148     bspIterator != BspEntity::objectList().end();
     149     bspIterator++)
     150{
     151  float res = (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollisionRay( pos, dir, dir.len() + 1 );
     152
     153  if ( res < shortestDist )
     154    shortestDist = res;
     155}
     156
     157WorldEntity* target = aimingSystem->getNearestTarget();
     158aimingSystem->flushList();
     159
     160if ( target != NULL )
     161{
     162  if ( shortestDist < (pos - target->getAbsCoor()).len() )
     163  {
     164    printf("HIT WALL\n");
     165    return;
     166  }
     167  if (!alwaysHits)
     168  {
     169    float r = rand();
     170    r = r/RAND_MAX;
     171    float res = (target->getAbsCoor() - this->getAbsCoor()).len();
     172    float p = 1 - res*res/range/range;
     173    if (r < p )
     174    {
     175      printf( "HIT %s\n", target->getClassName().c_str() );
     176      target->hit( this->damage, this );
     177    }
     178    else
     179      printf( "MISHIT %s\n", target->getClassName().c_str() );
     180
     181  }
     182  else
     183  {
     184    printf( "HIT %s\n", target->getClassName().c_str() );
     185    target->hit( this->damage, this );
     186  }
     187}
     188
     189
     190
    183191       
    184192}
  • branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc

    r10705 r10710  
    8181  this->registerObject(this, FPSSniperRifle::_objectList);
    8282
    83   this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2);
     83  this->setAbsDir( this->getAbsDir() * Quaternion( -PI/2, Vector(1, 0, 0) ) );
     84  this->loadModel("models/guns/fps_sniper_rifle.obj", 1.5);
    8485  this->material = new Material();
    8586  this->material->setIllum(3);
    8687  this->material->setAmbient(1.0, 1.0, 1.0);
    87   this->material->setDiffuseMap("textures/rifle01tex.jpg");
     88  this->material->setDiffuseMap("textures/fps_sniper_rifle.jpg");
    8889
    8990  this->setStateDuration(WS_SHOOTING, .1);
     
    169170  glPushMatrix();
    170171
    171   Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 2, 0, 0 ) );
     172  Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) );
    172173  glTranslatef (pos.x,
    173174                pos.y,
  • branches/presentation/src/world_entities/world_entity.cc

    r10708 r10710  
    9999 
    100100  this->forwardDamageToParent = false;
     101  this->damageable = false;
    101102
    102103  // registering default reactions:
     
    183184 
    184185  LoadParam(root, "forwardDamageToParent", this, WorldEntity, setForwardDamageToParent);
     186 
     187  LoadParam(root, "damageable", this, WorldEntity, setDamageable);
    185188
    186189  // Track
     
    994997  bool dead = this->getHealth()<=0;
    995998 
     999  if ( !damageable )
     1000    return;
     1001 
    9961002  this->decreaseHealth(damage);
    9971003
  • branches/presentation/src/world_entities/world_entity.h

    r10708 r10710  
    239239  void setElectronicTH(float th) { this->electronicTH = th; };
    240240  void setElectronicRegen(float regen) { this->electronicRegen = regen; };
     241 
     242  void setDamageable( bool damageable ){ this->damageable = damageable; }
     243  bool getDamageable(){ return this->damageable; }
    241244
    242245  inline void drawDebugTrack(int flag) { this->bDrawTrack = (bool)flag; }
     
    263266
    264267
     268  bool                    damageable;             //!< weather this we can be damaged/killed
    265269  float                   damage;                 //!< the damage dealt to other objects by colliding.
    266270  float                   health;                 //!< The Energy of this Entity, if the Entity has any energy at all.
Note: See TracChangeset for help on using the changeset viewer.