void TaskForceClass::ReturnToSearch (void) { if (missiles_flying < 1 && IsEmitting()) { radar_mode = search_mode; if (radar_mode == FEC_RADAR_OFF) SetEmitting(0); } else if (!IsEmitting()) radar_mode = FEC_RADAR_OFF; }
void Emitter::Update(double elapsed) { Array <int> particlesToRemove; //eliminacion de particulas for( unsigned int i = 0; i < particles.Size(); i++ ) { particles[i]->Update( elapsed ); for( unsigned int a = 0; a < affectors.Size(); a++ ) affectors[a].AddParticles( particles[i] ); if( particles[i]->GetLifetime() <= 0 ) { particlesToRemove.Add( i ); delete particles[i]; for( unsigned int a = 0; a < affectors.Size(); a++ ) affectors[a].DeleteParticles( particles[i] ); } } for( int i = particlesToRemove.Size() - 1; i >= 0 ; i-- ) { particles.RemoveAt( particlesToRemove[i] ); } //fin eliminacion particulas //creacion de particulas int32 nParticles = 0; double velX, velY, velAng, life; uint8 r, g, b; if( IsEmitting() ) { nParticles = static_cast<int32>( RangeRand( static_cast<int32>( minrate ), static_cast<int32>( maxrate ) ) * elapsed ); } for( uint32 i = 0; i < (uint32)nParticles; i++ ) { velX = RangeRand( minvelx, maxvelx ); velY = RangeRand( minvely, maxvely ); velAng = RangeRand( minangvel, maxangvel ); life = RangeRand( minlifetime, maxlifetime) ; r = (uint8)RangeRand( minr, maxr ); g = (uint8)RangeRand( ming, maxg ); b = (uint8)RangeRand( minb, maxb ); Particle *particle = new Particle( image, velX, velY, velAng, life, autofade ); particle->SetPosition( x, y ); particle->SetColor( r, g, b, 255 ); particle->SetBlendMode( blendMode ); particles.Add( particle ); } //fin creacion particulas }
int TaskForceClass::ChooseTarget (void) { FalconEntity *artTarget,*react_against=NULL,*air_react_against=NULL; CampEntity e; float d,react_distance,air_react_distance; int react,best_reaction=1,best_air_react=1,combat,retval=0,pass=0,spot=0,estr=0,capture=0,nomove=0; int search_dist; Team who; if (IsChecked()) return Engaged(); who = GetTeam(); react_distance = air_react_distance = 9999.0F; #ifdef DEBUG DWORD timec = GetTickCount(); #endif // Special case for fire support if (Targeted()) artTarget = GetTarget(); // Save our target else artTarget = NULL; SetEngaged(0); SetCombat(0); SetChecked(); search_dist = GetDetectionRange(Air); if (search_dist < MAX_GROUND_SEARCH) search_dist = MAX_GROUND_SEARCH; #ifdef VU_GRID_TREE_Y_MAJOR VuGridIterator detit(RealUnitProxList,YPos(),XPos(),(BIG_SCALAR)GridToSim(search_dist)); #else VuGridIterator detit(RealUnitProxList,XPos(),YPos(),(BIG_SCALAR)GridToSim(search_dist)); #endif // CalculateSOJ(detit); 2002-02-19 REMOVED BY S.G. eFalcon 1.10 SOJ code removed e = (CampEntity)detit.GetFirst(); while (e) { if (GetRoE(who,e->GetTeam(),ROE_GROUND_FIRE) == ROE_ALLOWED) { combat = 0; react = DetectVs(e,&d,&combat,&spot); if (!e->IsFlight() && react >= best_reaction && d < react_distance) { // React vs a ground/Naval target best_reaction = react; react_distance = d; react_against = e; SetEngaged(1); SetCombat(combat); } else if (e->IsFlight() && react >= best_air_react && d < air_react_distance) { // React vs an air target - best_air_react = react; air_react_distance = d; air_react_against = e; if (!e->IsAggregate()) { // Pick a specific aircraft in the flight if it's deaggregated CampEnterCriticalSection(); if (e->GetComponents()) { VuListIterator cit(e->GetComponents()); FalconEntity *fe; float rsq,brsq=FLT_MAX; fe = (FalconEntity *)cit.GetFirst(); while (fe) { rsq = DistSqu(XPos(),YPos(),fe->XPos(),fe->YPos()); if (rsq < brsq) { air_react_against = fe; air_react_distance = (float)sqrt(rsq); brsq = rsq; } fe = (FalconEntity *)cit.GetNext(); } } CampLeaveCriticalSection(); } // Make sure our radar is on (if we have one) if (!IsEmitting() && class_data->RadarVehicle < 255 && GetNumVehicles(class_data->RadarVehicle)) SetEmitting(1); SetEngaged(1); SetCombat(combat); } } e = (CampEntity)detit.GetNext(); } SetOdds ((GetTotalVehicles() * 10) / (estr+10)); if (!Parent() && best_reaction > 1) EngageParent(this,react_against); if (air_react_against) { SetAirTarget(air_react_against); retval = 1; } if (react_against) { SetTarget(react_against); SetTargeted(0); retval = 1; } else if (artTarget && (!artTarget->IsUnit() || ((Unit)artTarget)->Engaged()) && orders == GORD_SUPPORT) { // Keep blowing away this target until the target gets out of range, disengages, or we get new orders // (Target will get reset after a null DoCombat result) SetTarget(artTarget); SetTargeted(1); SetEngaged(1); SetCombat(1); return -1; // We want to sit here and shoot until we can't any longer } if (nomove) return -1; return retval; }