Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
warpto.h File Reference

Go to the source code of this file.

Functions

bool DistanceWarrantsWarpTo (Unit *parent, float sigdistance, bool following)
 
bool DistanceWarrantsTravelTo (Unit *parent, float sigdistance, bool following)
 
bool TargetWorthPursuing (Unit *parent, Unit *target)
 
void WarpToP (Unit *parent, Unit *target, bool following)
 
void WarpToP (Unit *parent, const QVector &target, float radius, bool following)
 

Function Documentation

bool DistanceWarrantsTravelTo ( Unit parent,
float  sigdistance,
bool  following 
)

Definition at line 41 of file warpto.cpp.

References Unit::GetComputerData(), Unit::GetVelocityDifficultyMult(), max_allowable_travel_time(), and Unit::Computer::max_combat_speed.

Referenced by Orders::DockingOps::Movement().

42 {
43  //first let us decide whether the target is far enough to warrant using warp
44  float diff = 1;
45  parent->GetVelocityDifficultyMult( diff );
46  float timetolive = dist/(diff*parent->GetComputerData().max_combat_speed);
47  if ( timetolive > max_allowable_travel_time() )
48  return true;
49  return false;
50 }
bool DistanceWarrantsWarpTo ( Unit parent,
float  sigdistance,
bool  following 
)

Definition at line 12 of file warpto.cpp.

References Unit::GetComputerData(), VegaConfig::getVariable(), Unit::GetVelocityDifficultyMult(), Unit::GetWarpVelocity(), max_allowable_travel_time(), Unit::Computer::max_combat_speed, XMLSupport::parse_bool(), XMLSupport::parse_float(), SIMULATION_ATOM, and vs_config.

13 {
14  //first let us decide whether the target is far enough to warrant using warp
15  //double dist =UnitUtil::getSignificantDistance(parent,target);
16  static float tooclose = XMLSupport::parse_float( vs_config->getVariable( "AI", "too_close_for_warp_tactic", "13000" ) );
17  static float tooclosefollowing =
18  XMLSupport::parse_float( vs_config->getVariable( "AI", "too_close_for_warp_in_formation", "1500" ) );
19  float toodamnclose = following ? tooclosefollowing : tooclose;
20  float diff = 1;
21  parent->GetVelocityDifficultyMult( diff );
22  float timetolive = dist/(diff*parent->GetComputerData().max_combat_speed);
23  if ( timetolive > ( 5*max_allowable_travel_time() ) ) {
24  return true;
25  } else if ( timetolive > ( max_allowable_travel_time() ) ) {
26  float mytime = SIMULATION_ATOM*1.5;
27  static bool rampdown = XMLSupport::parse_bool( vs_config->getVariable( "physics", "autopilot_ramp_warp_down", "true" ) );
28  if (rampdown == false) {
29  static float warprampdowntime =
30  XMLSupport::parse_float( vs_config->getVariable( "physics", "warprampdowntime", "0.5" ) );
31  mytime = warprampdowntime;
32  }
33  if (dist-parent->GetWarpVelocity().Magnitude()*mytime < toodamnclose)
34  return false; //avoid nasty jitter-jumping behavior should eventually have "running away check"
35 
36  return true;
37  }
38  return false;
39 }
bool TargetWorthPursuing ( Unit parent,
Unit target 
)

Definition at line 52 of file warpto.cpp.

Referenced by WarpToP().

53 {
54  return true;
55 }
void WarpToP ( Unit parent,
Unit target,
bool  following 
)

Definition at line 88 of file warpto.cpp.

References ActuallyWarpTo(), Unit::AutoPilotTo(), DistanceWarrantsWarpTo(), UnitUtil::getSignificantDistance(), VegaConfig::getVariable(), Unit::GetVelocity(), Unit::graphicOptions, Unit::graphic_options::InWarp, XMLSupport::parse_bool(), Unit::Position(), TargetWorthPursuing(), and vs_config.

Referenced by Orders::AggressiveAI::Execute(), Orders::FormUp::Execute(), Orders::FormUpToOwner::Execute(), FlyTo::Execute(), Orders::AggressiveAI::ExecuteNoEnemies(), and Orders::DockingOps::Movement().

89 {
90  float dist = UnitUtil::getSignificantDistance( parent, target );
91  if ( DistanceWarrantsWarpTo( parent, dist, following ) ) {
92  if ( TargetWorthPursuing( parent, target ) ) {
93  static bool auto_valid =
94  XMLSupport::parse_bool( vs_config->getVariable( "physics", "insystem_jump_or_timeless_auto-pilot", "false" ) );
95  if (auto_valid) {
96  std::string tmp;
97  parent->AutoPilotTo( target, false );
98  } else {
99  ActuallyWarpTo( parent, target->Position(), target->GetVelocity(), target );
100  }
101  }
102  } else {
103  parent->graphicOptions.InWarp = 0;
104  }
105 }
void WarpToP ( Unit parent,
const QVector target,
float  radius,
bool  following 
)

Definition at line 107 of file warpto.cpp.

References ActuallyWarpTo(), DistanceWarrantsWarpTo(), VegaConfig::getVariable(), Unit::graphicOptions, Unit::graphic_options::InWarp, Magnitude(), XMLSupport::parse_bool(), Unit::Position(), QVector, Unit::rSize(), and vs_config.

108 {
109  float dist = (parent->Position()-target).Magnitude()-radius-parent->rSize();
110  if ( DistanceWarrantsWarpTo( parent, dist, following ) ) {
111  static bool auto_valid =
112  XMLSupport::parse_bool( vs_config->getVariable( "physics", "insystem_jump_or_timeless_auto-pilot", "false" ) );
113  if (!auto_valid)
114  ActuallyWarpTo( parent, target, QVector( 0, 0, .00001 ) );
115  } else {
116  parent->graphicOptions.InWarp = 0;
117  }
118 }