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

  1. #include "Chaingun.h"
  2.  
  3. #include "Game.h"
  4. #include "log.h"
  5. #include "random.h"
  6.  
  7. Chaingun::Chaingun(Vehicle* vehicle, vec3_t mountPoint): Weapon(vehicle, mountPoint){
  8.     this->type = GAME_WEAPON_CHAINGUN;
  9.     this->name = "Chaingun";
  10.     this->model = Game::preloadedGameMedia.chaingunModel;
  11.  
  12.     this->maxAmmo = 300;
  13.     this->ammo = 300;
  14.     this->ammoCosts = 1;
  15.     this->maxEnergy = 0;
  16.     this->energy = 0.0f;
  17.     this->energyCosts = 0;
  18.  
  19.     fireIntervalMillis = 75;
  20.     vectorInit3d(0.0f, -0.144f, 0.94f, muzzlePoint);
  21.  
  22.     this->animator = new Animator( *Game::preloadedGameMedia.chaingunAnimator );
  23. }
  24.  
  25. void Chaingun::fire(){
  26. //    if(!isReadyToFire())
  27. //        return;
  28.  
  29. //    log("CHAINGUN FIRED!\n");
  30.     energy -= energyCosts;
  31.     if( energy < 0.0f )
  32.         energy = 0.0f;
  33.  
  34.     ammo -= ammoCosts;
  35.     if( ammo < 0 )
  36.         ammo = 0;
  37.  
  38.     Shot* s = Shot::createShotForWeapon(this);
  39.  
  40.     vec3_t normal;
  41.     float u = frand(-1.0f, 1.0f);
  42.     float v = frand(-1.0f, 1.0f);
  43.     vectorLinCombi3d(u, s->left, v, s->up, normal);
  44.     vectorNormalize3d(normal, normal);
  45.     float angle = frand(0.05f);
  46.     vectorRotateAroundNormal3d(s->dir, normal, angle, s->dir);
  47.  
  48.     vehicle->client->sendShotSpawn(s);
  49.     delete s;
  50.  
  51.     lastFiredMillis = SDL_GetTicks();
  52.  
  53. //    Weapon::fire();
  54.     // TODO: tja, mach mal...
  55. }
  56.  
  57.