_type_str = "ballistic";
_otype = otBallistic;
drag_area = 0.007;
+ life_timer = 0.0;
}
FGAIBallistic::~FGAIBallistic() {
drag_area = a;
}
+void FGAIBallistic::setLife(double seconds) {
+ life = seconds;
+}
+
void FGAIBallistic::Run(double dt) {
+ life_timer += dt;
+ if (life_timer > life) setDie(true);
+
double speed_north_deg_sec;
double speed_east_deg_sec;
void setElevation( double el );
void setStabilization( bool val );
void setDragArea( double a );
+ void setLife( double seconds );
private:
double hs; // horizontal speed (fps)
bool aero_stabilized; // if true, object will point where it's going
double drag_area; // equivalent drag area in ft2
+ double life_timer; // seconds
void Run(double dt);
};
in_range = false;
invisible = true;
no_roll = true;
+ life = 900;
model_path = "";
model = 0;
_otype = otNull;
int id;
bool invisible;
bool no_roll;
+ double life;
FGAIFlightPlan *fp;
void Transform();
int FGAIManager::createBallistic( string path, double latitude, double longitude,
double altitude, double azimuth, double elevation,
- double speed, double eda ) {
+ double speed, double eda, double life ) {
FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
ai_list.push_back(ai_ballistic);
ai_ballistic->setLongitude(longitude);
ai_ballistic->setLatitude(latitude);
ai_ballistic->setDragArea(eda);
+ ai_ballistic->setLife(life);
ai_ballistic->init();
ai_ballistic->bind();
return ai_ballistic->getID();
} else if (en->aitype == "ballistic"){
createBallistic( en->model_path, en->latitude, en->longitude,
en->altitude, en->azimuth, en->elevation, en->speed,
- en->eda );
+ en->eda, en->life );
}
}
}
double azimuth, // in degrees (same as heading)
double elevation, // in degrees (same as pitch)
double speed, // in feet per second
- double eda ); // equivalent drag area, ft2
+ double eda, // equivalent drag area, ft2
+ double life ); // life span in seconds
int createStorm( string path, // path to exterior model
double latitude, // in degrees -90 to 90
en->strength = entry_node->getDoubleValue("strength-fps", 0.0);
en->diameter = entry_node->getDoubleValue("diameter-ft", 0.0);
en->eda = entry_node->getDoubleValue("eda", 0.007);
+ en->life = entry_node->getDoubleValue("life", 900.0);
}
entry_iterator = entries.begin();
double strength; // used by thermal objects
double diameter; // used by thermal objects
double eda; // used by ballistic objects
+ double life; // life span in seconds
} entry;
FGAIScenario(string filename);
//cout << "Creating a submodel." << endl;
int rval = ai->createBallistic( sm->model, IC.lat, IC.lon, IC.alt, IC.azimuth,
- IC.elevation, IC.speed, sm->drag_area );
+ IC.elevation, IC.speed, sm->drag_area, sm->life );
//cout << "Submodel created." << endl;
(sm->count)--;
sm->yaw_offset = entry_node->getDoubleValue("yaw-offset", 0.0);
sm->pitch_offset = entry_node->getDoubleValue("pitch-offset", 0.0);
sm->drag_area = entry_node->getDoubleValue("eda", 0.007);
+ sm->life = entry_node->getDoubleValue("life", 900.0);
sm->trigger->setBoolValue(false);
sm->timer = sm->delay;
double yaw_offset;
double pitch_offset;
double drag_area;
+ double life;
} submodel;
typedef struct {