home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / LaserShot.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-01-17  |  2.6 KB  |  96 lines

  1. #include "LaserShot.h"
  2.  
  3. #include "Game.h"
  4. #include "WeaponEffectsParticleClusters.h"
  5. #include "Network.h"
  6.  
  7. LaserShot::LaserShot(int clientId, int weaponId): Shot(clientId, weaponId, 10000){
  8.     this->type = GAME_WEAPON_LASER;
  9.     this->moveSpeed = 45.0f;
  10.     this->inflictedDamage = 8;
  11.  
  12.     this->model = Game::preloadedGameMedia.laserShotModel;
  13. }
  14.  
  15. LaserShot::~LaserShot(){
  16. }
  17.  
  18. void LaserShot::leaveMuzzle(){
  19.     if( Renderer::info.var.useDynamicLighting ){
  20.         vec3_t col;
  21.         vectorInit3d(0.2f, 0.6f, 0.7f, col);
  22.         Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(pos, col, 1.0f, 10) );
  23.     }
  24.  
  25.     if( Sound::info.var.enabled && Sound::info.var.playSamples ){
  26.         Sound::playEffect(pos, Game::preloadedGameMedia.laserFireSound, 0);
  27.     }
  28.  
  29.     Shot::leaveMuzzle(); // animation and some other stuff
  30. }
  31.  
  32.  
  33. void LaserShot::hitFace(Face* face, vec3_t hp){
  34.     if( Renderer::info.var.useDynamicLighting ){
  35.         vec3_t col;
  36.         vectorInit3d(0.1f, 0.4f, 0.5f, col);
  37.         Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(hp, col, 4.0f, 100) );
  38.     }
  39.  
  40.     if( Renderer::info.var.renderParticleEffects >= 2 ){
  41.         vec3_t p;
  42.         vectorMA3d(hp, 0.05f, face->normal, p);
  43.         Renderer::particleSystem.linkParticleCluster( new SmallSmokePuffParticleCluster(p) );
  44.     }
  45.  
  46.     if( Renderer::info.var.renderParticleEffects >= 3 ){
  47.         Renderer::particleSystem.linkParticleCluster( new LaserMarkParticleCluster(hp, face) );
  48.     }
  49.  
  50.     if( Sound::info.var.enabled && Sound::info.var.playSamples ){
  51.         Sound::playEffect(hp, Game::preloadedGameMedia.laserImpactSound, 0);
  52.     }
  53.  
  54.     Shot::hitFace(face, hp);
  55. }
  56.  
  57. void LaserShot::hitVehicle(Vehicle* vehicle, vec3_t hp){
  58.     if( Renderer::info.var.useDynamicLighting ){
  59.         vec3_t col;
  60.         vectorInit3d(0.1f, 0.4f, 0.5f, col);
  61.         Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(hp, col, 4.0f, 100) );
  62.     }
  63.  
  64.     if( Renderer::info.var.renderParticleEffects >= 2 ){
  65.         Renderer::particleSystem.linkParticleCluster( new SmallSmokePuffParticleCluster(hp) );
  66.     }
  67.  
  68.     if( Sound::info.var.enabled && Sound::info.var.playSamples ){
  69.         Sound::playEffect(hp, Game::preloadedGameMedia.laserImpactSound, 0);
  70.     }
  71.  
  72.     // push
  73.     vec3_t pushForce;
  74.     vectorScale3d(200.0f , this->dir, pushForce);
  75.     vehicle->physicsInfo.addPushForce(pushForce, 50);
  76.  
  77.     Shot::hitVehicle(vehicle, hp);
  78. }
  79.  
  80.  
  81. void LaserShot::render(){
  82.     glPushMatrix();
  83.     float m[] = {    left[0], left[1], left[2], 0.0f,
  84.                     up[0], up[1], up[2], 0.0f,
  85.                     dir[0], dir[1], dir[2], 0.0f,
  86.                     pos[0], pos[1], pos[2], 1.0f
  87.                 };
  88.     glMultMatrixf(m);
  89.  
  90.     Renderer::renderModel(model);
  91.  
  92.     glPopMatrix();
  93. }
  94.  
  95.  
  96.