- Timestamp:
- Jun 17, 2007, 2:25:20 PM (18 years ago)
- Location:
- branches/presentation/src/world_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/world_entities/npcs/npc.cc
r10698 r10710 440 440 441 441 // 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) 443 443 { 444 444 this->destroy( killer); 445 445 this->setDamage(killer->getDamage()); 446 } 446 }*/ -
branches/presentation/src/world_entities/npcs/npc.h
r10546 r10710 37 37 void destroy( WorldEntity* killer ); 38 38 39 void hit( float damage, WorldEntity* killer);39 //void hit( float damage, WorldEntity* killer); 40 40 41 41 inline void destroyThis() { this->destroy(NULL);}; -
branches/presentation/src/world_entities/weapons/bsp_weapon.cc
r10709 r10710 133 133 //gunFirExpl.explode(gunFire2,Vector(2,2,2)); 134 134 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 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 { 151 float res = (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollisionRay( pos, dir, dir.len() + 1 ); 152 153 if ( res < shortestDist ) 154 shortestDist = res; 155 } 156 157 WorldEntity* target = aimingSystem->getNearestTarget(); 158 aimingSystem->flushList(); 159 160 if ( 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 183 191 184 192 } -
branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc
r10705 r10710 81 81 this->registerObject(this, FPSSniperRifle::_objectList); 82 82 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); 84 85 this->material = new Material(); 85 86 this->material->setIllum(3); 86 87 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"); 88 89 89 90 this->setStateDuration(WS_SHOOTING, .1); … … 169 170 glPushMatrix(); 170 171 171 Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 2, 0, 0 ) );172 Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) ); 172 173 glTranslatef (pos.x, 173 174 pos.y, -
branches/presentation/src/world_entities/world_entity.cc
r10708 r10710 99 99 100 100 this->forwardDamageToParent = false; 101 this->damageable = false; 101 102 102 103 // registering default reactions: … … 183 184 184 185 LoadParam(root, "forwardDamageToParent", this, WorldEntity, setForwardDamageToParent); 186 187 LoadParam(root, "damageable", this, WorldEntity, setDamageable); 185 188 186 189 // Track … … 994 997 bool dead = this->getHealth()<=0; 995 998 999 if ( !damageable ) 1000 return; 1001 996 1002 this->decreaseHealth(damage); 997 1003 -
branches/presentation/src/world_entities/world_entity.h
r10708 r10710 239 239 void setElectronicTH(float th) { this->electronicTH = th; }; 240 240 void setElectronicRegen(float regen) { this->electronicRegen = regen; }; 241 242 void setDamageable( bool damageable ){ this->damageable = damageable; } 243 bool getDamageable(){ return this->damageable; } 241 244 242 245 inline void drawDebugTrack(int flag) { this->bDrawTrack = (bool)flag; } … … 263 266 264 267 268 bool damageable; //!< weather this we can be damaged/killed 265 269 float damage; //!< the damage dealt to other objects by colliding. 266 270 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.