Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.