int Cockpit::Autopilot( Unit *target ) { int retauto = 0; if (target) { Unit *un = NULL; if ( ( un = GetParent() ) ) { if ( ( retauto = un->AutoPilotTo( un, false ) ) ) { //can he even start to autopilot //SetView (CP_PAN); un->AutoPilotTo( target, false ); static bool face_target_on_auto = XMLSupport::parse_bool( vs_config->getVariable( "physics", "face_on_auto", "false" ) ); if (face_target_on_auto) FaceTarget( un ); static double averagetime = GetElapsedTime()/getTimeCompression(); static double numave = 1.0; averagetime += GetElapsedTime()/getTimeCompression(); //static float autospeed = XMLSupport::parse_float (vs_config->getVariable ("physics","autospeed",".020"));//10 seconds for auto to kick in; numave++; /* * AccessCamera(CP_PAN)->myPhysics.SetAngularVelocity(Vector(0,0,0)); * AccessCamera(CP_PAN)->myPhysics.ApplyBalancedLocalTorque(_Universe->AccessCamera()->P, * _Universe->AccessCamera()->R, * averagetime*autospeed/(numave)); */ static float initialzoom = XMLSupport::parse_float( vs_config->getVariable( "graphics", "inital_zoom_factor", "2.25" ) ); zoomfactor = initialzoom; static float autotime = XMLSupport::parse_float( vs_config->getVariable( "physics", "autotime", "10" ) ); //10 seconds for auto to kick in; autopilot_time = autotime; autopilot_target.SetUnit( target ); } } } return retauto; }
void Cockpit::UpdAutoPilot() { if (autopilot_time != 0) { autopilot_time -= SIMULATION_ATOM; if (autopilot_time <= 0) { autopilot_time = 0; Unit *par = GetParent(); if (par) { Unit *autoun = autopilot_target.GetUnit(); autopilot_target.SetUnit( NULL ); if (autoun) par->AutoPilotTo( autoun, false ); } } } }