home *** CD-ROM | disk | FTP | other *** search
- #include "ArenaEffectsParticleClusters.h"
-
- #include "Renderer.h"
- #include "Network.h"
- #include "Vehicle.h"
- #include "intersection.h"
- #include "Game.h"
-
- //Model* SupplyPadEffectParticleCluster::model = NULL;
-
-
- SupplyPadEffectParticleCluster::SupplyPadEffectParticleCluster(vec3_t pos):ParticleCluster(86400000) { // 1 day lifetime
- importance = 1;
- vectorCopy3d(pos, this->pos);
- lastImpulseMillis = 0;
- model = Game::preloadedGameMedia.supplyPadCylindersModel;
- activeSound = Game::preloadedGameMedia.supplyPadActiveSound;
- impulseSound = Game::preloadedGameMedia.supplyPadImpulseSound;
-
- boundingSphereRadius = 5.0f;
- }
-
- SupplyPadEffectParticleCluster::~SupplyPadEffectParticleCluster(){
- // printf("dest\n");
- }
-
- void SupplyPadEffectParticleCluster::move(){
- unsigned long currentMillis = SDL_GetTicks();
- bool dlpcAdded = false;
-
- if( lastImpulseMillis + 500 < currentMillis ){
- for(int i=0;i<GAME_MAX_VEHICLES;i++){
- if( Game::vehicles[i] == NULL )
- continue;
-
- vec3_t relPos;
- vectorSub3d(Game::vehicles[i]->pos, pos, relPos);
- relPos[1] -= 1.3f;
- if( pointIntersectsAABB(relPos, Game::vehicles[i]->moveAABB.min, Game::vehicles[i]->moveAABB.max) ){
- Vehicle* v = Game::vehicles[i];
- // add energy & armor
- v->energy += 10;
- v->armor += 10;
- if( v->energy > v->maxEnergy )
- v->energy = v->maxEnergy;
- if( v->armor > v->maxArmor )
- v->armor = v->maxArmor;
-
- for(int k=0;k<4;k++){
- if( v->weapons[k] == NULL )
- continue;
-
- if( v->weapons[k]->maxEnergy > 0 ){
- v->weapons[k]->energy += 10.0f;
- if( v->weapons[k]->energy > v->weapons[k]->maxEnergy ){
- v->weapons[k]->energy = v->weapons[k]->maxEnergy;
- }
- }
- if( v->weapons[k]->maxAmmo > 0 ){
- v->weapons[k]->ammo += (int)( 0.1f * v->weapons[k]->maxAmmo );
- if( v->weapons[k]->ammo > v->weapons[k]->maxAmmo ){
- v->weapons[k]->ammo = v->weapons[k]->maxAmmo;
- }
- }
- }
-
- // play sound
- if( Sound::info.var.enabled && Sound::info.var.playSamples ){
- Sound::playEffect(pos, impulseSound);
- }
-
- // add light impulse if it's not there already
- if( !dlpcAdded && Renderer::info.var.useDynamicLighting ){
- vec3_t col, lightPos;
- vectorInit3d(0.3f, 0.5f, 0.8f, col);
- vectorInit3d(pos[0], pos[1]+1.0f, pos[2], lightPos);
- Renderer::particleSystem.linkParticleCluster(new DynamicLightParticleCluster(lightPos, col, 4.0f, 100));
-
- dlpcAdded = true;
- }
- }
-
- }
-
- lastImpulseMillis = currentMillis;
- }
-
- lifetimeMillis = currentMillis + 60000; // for one more hour!
- // printf("move\n");
- }
-
- void SupplyPadEffectParticleCluster::render(){
- for(int i=0;i<GAME_MAX_VEHICLES;i++){
- if( Game::vehicles[i] == NULL )
- continue;
-
- vec3_t relPos;
- vectorSub3d(Game::vehicles[i]->pos, pos, relPos);
- relPos[1] -= 1.3f;
- if( pointIntersectsAABB(relPos, Game::vehicles[i]->moveAABB.min, Game::vehicles[i]->moveAABB.max) ){
- glPushMatrix();
- glTranslatef(pos[0], pos[1], pos[2]);
- Renderer::renderModel(model);
- glPopMatrix();
-
- break; // only one effect, no matter how many are standing on pad
- }
-
-
- }
- // printf("render\n");
- }
-
-
-
-
-
-
-
-
-
-