home *** CD-ROM | disk | FTP | other *** search
- #include "Chaingun.h"
-
- #include "Game.h"
- #include "log.h"
- #include "random.h"
-
- Chaingun::Chaingun(Vehicle* vehicle, vec3_t mountPoint): Weapon(vehicle, mountPoint){
- this->type = GAME_WEAPON_CHAINGUN;
- this->name = "Chaingun";
- this->model = Game::preloadedGameMedia.chaingunModel;
-
- this->maxAmmo = 300;
- this->ammo = 300;
- this->ammoCosts = 1;
- this->maxEnergy = 0;
- this->energy = 0.0f;
- this->energyCosts = 0;
-
- fireIntervalMillis = 75;
- vectorInit3d(0.0f, -0.144f, 0.94f, muzzlePoint);
-
- this->animator = new Animator( *Game::preloadedGameMedia.chaingunAnimator );
- }
-
- void Chaingun::fire(){
- // if(!isReadyToFire())
- // return;
-
- // log("CHAINGUN FIRED!\n");
- energy -= energyCosts;
- if( energy < 0.0f )
- energy = 0.0f;
-
- ammo -= ammoCosts;
- if( ammo < 0 )
- ammo = 0;
-
- Shot* s = Shot::createShotForWeapon(this);
-
- vec3_t normal;
- float u = frand(-1.0f, 1.0f);
- float v = frand(-1.0f, 1.0f);
- vectorLinCombi3d(u, s->left, v, s->up, normal);
- vectorNormalize3d(normal, normal);
- float angle = frand(0.05f);
- vectorRotateAroundNormal3d(s->dir, normal, angle, s->dir);
-
- vehicle->client->sendShotSpawn(s);
- delete s;
-
- lastFiredMillis = SDL_GetTicks();
-
- // Weapon::fire();
- // TODO: tja, mach mal...
- }
-
-