#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx>
-#include <Scenery/tilemgr.hxx>
#include "AIEscort.hxx"
FGAIShip(otEscort),
_relbrg (0),
-_stn_truebrg(0),
_parent_speed(0),
-_stn_limit(0),
-_stn_angle_limit(0),
-_stn_speed(0),
+_interval(0),
+_stn_truebrg(0),
_stn_height(0),
+_stn_speed(0),
+_stn_angle_limit(0),
+_stn_limit(0),
_max_speed(0),
-_interval(0),
_MPControl(false),
_patrol(false),
_stn_deg_true(false)
no_roll = false;
props->setStringValue("controls/parent-name", _parent.c_str());
- setParentNode();
- setParent();
- pos = _tgtpos;
- speed = _parent_speed;
- hdg = _parent_hdg;
+ if (setParentNode()){
+ setParent();
+ pos = _tgtpos;
+ speed = _parent_speed;
+ hdg = _parent_hdg;
+ }
return true;
}
}
-
void FGAIEscort::setParent()
{
double lat = _selected_ac->getDoubleValue("position/latitude-deg");
range = distance * SG_METER_TO_NM;
}
-double FGAIEscort::calcRelBearingDeg(double bearing, double heading)
-{
- double angle = bearing - heading;
- SG_NORMALIZE_RANGE(angle, -180.0, 180.0);
- return angle;
-}
-
double FGAIEscort::calcTrueBearingDeg(double bearing, double heading)
{
double angle = bearing + heading;
return angle;
}
-double FGAIEscort::calcRecipBearingDeg(double bearing)
-{
- double angle = bearing - 180;
- SG_NORMALIZE_RANGE(angle, 0.0, 360.0);
- return angle;
-}
-
SGVec3d FGAIEscort::getCartHitchPosAt(const SGVec3d& _off) const {
double hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg");
double pitch = _selected_ac->getDoubleValue("orientation/pitch-deg");
// these are the AI rules for the manoeuvring of escorts
if (_MPControl && _tgtrange > 4 * _stn_limit){
- SG_LOG(SG_GENERAL, SG_ALERT, "AIEscort: " << _name
+ SG_LOG(SG_AI, SG_ALERT, "AIEscort: " << _name
<< " re-aligning to MP pos");
pos = _tgtpos;
speed = 0;