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

  1. #include "PlasmagunShot.h"
  2.  
  3. #include "Game.h"
  4. #include "WeaponEffectsParticleClusters.h"
  5. #include "Network.h"
  6.  
  7. PlasmagunShot::PlasmagunShot(int clientId, int weaponId): Shot(clientId, weaponId, 10000){
  8.     this->type = GAME_WEAPON_PLASMAGUN;
  9.     this->moveSpeed = 30.0f;
  10.     this->inflictedDamage = 6;
  11.  
  12.     shader = Game::preloadedGameMedia.plasmagunShotShader;
  13. }
  14.  
  15. PlasmagunShot::~PlasmagunShot(){
  16. }
  17.  
  18. void PlasmagunShot::leaveMuzzle(){
  19.     if( Renderer::info.var.useDynamicLighting ){
  20.         vec3_t col;
  21.         vectorInit3d(0.2f, 0.4f, 0.8f, col);
  22.         Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(pos, col, 1.5f, 20) );
  23.     }
  24.  
  25.     if( Sound::info.var.enabled && Sound::info.var.playSamples ){
  26.         Sound::playEffect(pos, Game::preloadedGameMedia.plasmagunFireSound, 0);
  27.     }
  28.  
  29.     // push
  30.     if( Network::server->clients[clientId] != NULL && Network::server->clients[clientId]->vehicle != NULL ){
  31.         vec3_t pushForce;
  32.         vectorScale3d(-150.0f , this->dir, pushForce);
  33.         Network::server->clients[clientId]->vehicle->physicsInfo.addPushForce(pushForce, 30);
  34.     }
  35.  
  36.     Shot::leaveMuzzle(); // animation and some other stuff
  37. }
  38.  
  39.  
  40. void PlasmagunShot::hitFace(Face* face, vec3_t hp){
  41.     vec3_t p;
  42.     vectorMA3d(hp, 0.1f, face->normal, p);
  43.     Renderer::particleSystem.linkParticleCluster( new PlasmagunImpactParticleCluster(this, p) );
  44.  
  45.     if( Renderer::info.var.useDynamicLighting ){
  46.         vec3_t col;
  47.         vectorInit3d(0.2f, 0.4f, 0.8f, col);
  48.         Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(hp, col, 4.0f, 100) );
  49.     }
  50.  
  51.     if( Renderer::info.var.renderParticleEffects >= 3 ){
  52.         Renderer::particleSystem.linkParticleCluster( new PlasmagunMarkParticleCluster(hp, face) );
  53.     }
  54.  
  55.     if( Sound::info.var.enabled && Sound::info.var.playSamples ){
  56.         Sound::playEffect(hp, Game::preloadedGameMedia.plasmagunImpactSound, 0);
  57.     }
  58.  
  59.     Shot::hitFace(face, hp);
  60. }
  61.  
  62. void PlasmagunShot::hitVehicle(Vehicle* vehicle, vec3_t hp){
  63.     Renderer::particleSystem.linkParticleCluster( new PlasmagunImpactParticleCluster(this, hp) );
  64.  
  65.     if( Renderer::info.var.useDynamicLighting ){
  66.         vec3_t col;
  67.         vectorInit3d(0.2f, 0.4f, 0.8f, col);
  68.         Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(hp, col, 4.0f, 100) );
  69.     }
  70.  
  71.     if( Sound::info.var.enabled && Sound::info.var.playSamples ){
  72.         Sound::playEffect(hp, Game::preloadedGameMedia.plasmagunImpactSound, 0);
  73.     }
  74.  
  75.     // push
  76.     vec3_t pushForce;
  77.     vectorScale3d(200.0f , this->dir, pushForce);
  78.     vehicle->physicsInfo.addPushForce(pushForce, 50);
  79.  
  80.     Shot::hitVehicle(vehicle, hp);
  81. }
  82.  
  83. void PlasmagunShot::render(){
  84.     if( Renderer::info.var.useTransparentPolysList ){
  85.         Renderer::addBillboardToTransparentPolys(pos, 0.75f, 0.75f, shader, SDL_GetTicks() - spawntimeMillis);
  86.     }else{
  87.         shader->setup(SDL_GetTicks() - spawntimeMillis);
  88.         Renderer::renderBillboard(pos, 0.75f, 0.75f, shader);
  89.         shader->setdown();
  90.     }
  91. }
  92.  
  93.  
  94.