home *** CD-ROM | disk | FTP | other *** search
- #include "ChaingunShot.h"
-
- #include "Game.h"
- #include "Network.h"
- #include "WeaponEffectsParticleClusters.h"
- #include "random.h"
-
- ChaingunShot::ChaingunShot(int clientId, int weaponId): Shot(clientId, weaponId, 10000){
- this->type = GAME_WEAPON_CHAINGUN;
- this->moveSpeed = 5.0f;
- this->inflictedDamage = 2;
- }
-
- ChaingunShot::~ChaingunShot(){
- }
-
- void ChaingunShot::leaveMuzzle(){
- if( Renderer::info.var.useDynamicLighting ){
- vec3_t col;
- vectorInit3d(0.6f, 0.5f, 0.1f, col);
- Renderer::particleSystem.linkParticleCluster( new DynamicLightParticleCluster(pos, col, 1.0f, 20) );
- }
-
- Renderer::particleSystem.linkParticleCluster( new ChaingunMuzzleFlashParticleCluster(this) );
-
-
- if( Sound::info.var.enabled && Sound::info.var.playSamples ){
- Sound::playEffect(pos, Game::preloadedGameMedia.chaingunFireSound, 0);
- }
-
-
- // push
- if( Network::server->clients[clientId] != NULL && Network::server->clients[clientId]->vehicle != NULL ){
- vec3_t pushForce;
- vectorScale3d(-100.0f , this->dir, pushForce);
- Network::server->clients[clientId]->vehicle->physicsInfo.addPushForce(pushForce, 40);
- }
-
- Shot::leaveMuzzle(); // animation and some other stuff
- }
-
- void ChaingunShot::move(float deltaT){
- unsigned int i;
- trace_t trace;
- trace.ignoreFlags = 0 | COLLISION_FLAG_BACKFACES | COLLISION_FLAG_SHOOT_THROUGH;
-
- traceRay(pos, dir, &trace);
-
- for(i=0;i<trace.hits.size();i++){
- if( trace.hits[i].face != NULL ){ // hit a face of the arena
- hitFace( trace.hits[i].face, trace.hits[i].pos );
- break;
- }
- if( trace.hits[i].vehicle != NULL ){ // hit a vehicle
- if( trace.hits[i].vehicle == Network::server->clients[clientId]->vehicle )
- continue;
-
- hitVehicle( trace.hits[i].vehicle, trace.hits[i].pos);
- break;
- }
- }
-
-
- lifetimeMillis = 0;
- }
-
- void ChaingunShot::hitFace(Face* face, vec3_t hp){
- vec3_t p;
- vectorMA3d(hp, 0.05f, face->normal, p);
- Renderer::particleSystem.linkParticleCluster( new ChaingunImpactParticleCluster(this, p) );
-
- if( Renderer::info.var.renderParticleEffects >= 2 && frand() < 0.2f && vectorPointDistance3d(hp, pos) > 2.0f ){
- vec3_t sp;
- vectorMA3d(pos, 0.5f, dir, sp);
- Renderer::particleSystem.linkParticleCluster( new ChaingunRicochetParticleCluster(sp, p) );
- }
-
- if( Sound::info.var.enabled && Sound::info.var.playSamples ){
- int r = (int)(frand()*6);
- if( r < 3 ){
- Mix_Chunk* sound = Game::preloadedGameMedia.chaingunImpactSounds[face->material->surfaceType][r];
- if (sound != NULL ){
- Sound::playEffect(hp, sound, 0);
- }
- }
- }
-
-
- if( Renderer::info.var.renderParticleEffects >= 3 ){
- Renderer::particleSystem.linkParticleCluster( new ChaingunMarkParticleCluster(hp, face) );
- }
-
- Shot::hitFace(face, hp);
- }
-
- void ChaingunShot::hitVehicle(Vehicle* vehicle, vec3_t hp){
- Renderer::particleSystem.linkParticleCluster( new ChaingunImpactParticleCluster(this, hp) );
-
- if( frand() < 0.2f ){
- Renderer::particleSystem.linkParticleCluster( new ChaingunRicochetParticleCluster(pos, hp) );
- }
-
- if( Sound::info.var.enabled && Sound::info.var.playSamples ){
- Mix_Chunk* sound = Game::preloadedGameMedia.chaingunImpactSounds[MATERIAL_SURFACE_TYPE_METAL][0];
- if (sound != NULL ){
- Sound::playEffect(hp, sound, 0);
- }
- }
-
- // push
- vec3_t pushForce;
- vectorScale3d(100.0f , this->dir, pushForce);
- vehicle->physicsInfo.addPushForce(pushForce, 40);
-
- Shot::hitVehicle(vehicle, hp);
- }
-
- void ChaingunShot::render(){
- }
-
-
-