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
firekeyboard.cpp File Reference
#include <set>
#include "firekeyboard.h"
#include "flybywire.h"
#include "navigation.h"
#include "in_joystick.h"
#include "cmd/unit_generic.h"
#include "communication.h"
#include "gfx/cockpit.h"
#include "gfx/animation.h"
#include "audiolib.h"
#include "config_xml.h"
#include "cmd/images.h"
#include "cmd/planet.h"
#include "cmd/script/flightgroup.h"
#include "cmd/script/mission.h"
#include "vs_globals.h"
#include "gfx/car_assist.h"
#include "cmd/unit_util.h"
#include <algorithm>
#include "fire.h"
#include "docking.h"
#include "cmd/pilot.h"
#include "cmd/role_bitmask.h"
#include "cmd/script/pythonmission.h"
#include "networking/netclient.h"
#include "universe_util.h"

Go to the source code of this file.

Classes

struct  FIREKEYBOARDTYPE
 

Functions

bool toggle_pause ()
 
static FIREKEYBOARDTYPEg ()
 
void LeadMe (Unit *un, string directive, string speech, bool changetarget)
 
static void LeadMe (string directive, string speech, bool changetarget)
 
void ExamineWhenTargetKey ()
 
unsigned int DoSpeech (Unit *un, Unit *player_un, const FSM::Node &convNode)
 
UnitGetThreat (Unit *par, Unit *leader)
 
void HelpOut (bool crit, std::string conv)
 
static bool isNotTurretOwner (Unit *parent, Unit *un)
 
bool TargMission (Unit *me, Unit *target)
 
bool TargAll (Unit *me, Unit *target)
 
bool TargSig (Unit *me, Unit *target)
 
UnitgetTopLevelOwner ()
 
bool TargUn (Unit *me, Unit *target)
 
bool TargMissile (Unit *me, Unit *target)
 
bool TargIncomingMissile (Unit *me, Unit *target)
 
bool TargFront (Unit *me, Unit *target)
 
bool TargThreat (Unit *me, Unit *target)
 
bool TargNear (Unit *me, Unit *target)
 
bool getNearestTargetUnit (Unit *me, int iType)
 
bool ChooseTargets (Unit *me, bool(*typeofunit)(Unit *, Unit *), bool reverse)
 
void ChooseSubTargets (Unit *me)
 
static bool UnDockNow (Unit *me, Unit *targ)
 
void Enslave (Unit *, bool)
 
void abletodock (int dock)
 
static bool SuperDock (Unit *parent, Unit *target)
 
static bool TryDock (Unit *parent, Unit *targ, unsigned char playa, int severity)
 
static bool ExecuteRequestClearenceKey (Unit *parent, Unit *endt)
 
static void DoDockingOps (Unit *parent, Unit *targ, unsigned char playa, unsigned char gender)
 
static void MyFunction ()
 
static CommunicationMessageGetTargetMessageQueue (Unit *targ, std::list< CommunicationMessage > &messagequeue)
 
void Arrested (Unit *parent)
 
void PowerDownShield (Shield *shield, float howmuch)
 
static void ForceChangeTarget (Unit *parent)
 
int SelectDockPort (Unit *utdw, Unit *parent)
 

Variables

const unsigned int NUMCOMMKEYS = 10
 
static std::vector
< FIREKEYBOARDTYPE
vectorOfKeyboardInput
 
std::set< Unit * > arrested_list_do_not_dereference
 

Function Documentation

void abletodock ( int  dock)

Definition at line 1247 of file firekeyboard.cpp.

Referenced by BaseInterface::Room::Launch::Click(), BaseInterface::Room::Eject::Click(), CrashForceDock(), DoDockingOps(), Unit::EjectCargo(), and TryDock().

1248 {
1249  static bool play_anim = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "docking_comm_anim", "false" ) );
1250  switch (dock)
1251  {
1252  case 5:
1253  {
1254  static soundContainer reqsound;
1255  if (reqsound.sound == -2) {
1256  static string str = vs_config->getVariable( "cockpitaudio", "undocking_complete", "undocking_complete" );
1257  reqsound.loadsound( str );
1258  }
1259  reqsound.playsound();
1260  break;
1261  }
1262  case 4:
1263  {
1264  static soundContainer reqsound;
1265  if (reqsound.sound == -2) {
1266  static string str = vs_config->getVariable( "cockpitaudio", "undocking_failed", "undocking_failed" );
1267  reqsound.loadsound( str );
1268  }
1269  reqsound.playsound();
1270  break;
1271  }
1272  case 3:
1273  {
1274  static soundContainer reqsound;
1275  static string otherstr = vs_config->getVariable( "audio", "automatic_docking_zone", "automatic_landing_zone.wav" );
1276  if (otherstr != "" && rand() < RAND_MAX/2) {
1277  static int s = AUDCreateSoundWAV( otherstr, false );
1278  AUDPlay( s, QVector( 0, 0, 0 ), Vector( 0, 0, 0 ), 1 );
1279  } else {
1280  if (reqsound.sound == -2) {
1281  static string str = vs_config->getVariable( "cockpitaudio", "docking_complete", "docking_complete" );
1282  reqsound.loadsound( str );
1283  }
1284  reqsound.playsound();
1285  }
1286  break;
1287  }
1288  case 2:
1289  {
1290  static soundContainer reqsound;
1291  if (reqsound.sound == -2) {
1292  static string str = vs_config->getVariable( "cockpitaudio", "docking_failed", "docking_failed" );
1293  reqsound.loadsound( str );
1294  }
1295  reqsound.playsound();
1296  break;
1297  }
1298  case 1:
1299  {
1300  static soundContainer reqsound;
1301  if (reqsound.sound == -2) {
1302  static string str = vs_config->getVariable( "cockpitaudio", "docking_granted", "request_granted" );
1303  reqsound.loadsound( str );
1304  }
1305  reqsound.playsound();
1306  break;
1307  }
1308  case 0:
1309  {
1310  static soundContainer reqsound;
1311  if (reqsound.sound == -2) {
1312  static string str = vs_config->getVariable( "cockpitaudio", "docking_denied", "request_denied" );
1313  reqsound.loadsound( str );
1314  }
1315  reqsound.playsound();
1316  break;
1317  }
1318  }
1319 }
void Arrested ( Unit parent)

Definition at line 1530 of file firekeyboard.cpp.

References _Universe, Universe::activeStarSystem(), UniverseUtil::adjustRelationModifier(), UniverseUtil::adjustRelationModifierInt(), Unit::aistate, Cargo::content, UnitCollection::createIterator(), Unit::faction, Unit::GetCargo(), FactionUtil::GetContraband(), FactionUtil::GetFactionIndex(), Unit::getFlightgroup(), UniverseUtil::GetGalaxyFaction(), Unit::getRelation(), UnitUtil::getRelationFromFaction(), UnitUtil::getRelationToFaction(), UniverseUtil::getSystemFile(), StarSystem::getUnitList(), UnitUtil::getUnitSystemFile(), VegaConfig::getVariable(), i, UniverseUtil::IOmessage(), Unit::isJumppoint(), UnitUtil::isSignificant(), j, UnitUtil::JumpTo(), Unit::name, Unit::numCargo(), UnitUtil::owner(), Unit::PrimeOrders(), Cargo::quantity, Unit::RemoveCargo(), Unit::Target(), vs_config, and Universe::whichPlayerStarship().

Referenced by FireKeyboard::Execute().

1531 {
1533  int own = FactionUtil::GetFactionIndex( fac );
1534  static string po = vs_config->getVariable( "galaxy", "police_faction", "homeland-security" );
1535  int police = FactionUtil::GetFactionIndex( po );
1536  int police2 = FactionUtil::GetFactionIndex( po+"_"+fac );
1537  float ownrel = UnitUtil::getRelationFromFaction( parent, own );
1538  bool attack = ownrel < 0;
1539  if (!attack) {
1540  Unit *contra = FactionUtil::GetContraband( own );
1541  if (contra) {
1542  for (unsigned int i = 0; (!attack) && i < parent->numCargo(); ++i) {
1543  Cargo *ci = &parent->GetCargo( i );
1544  for (unsigned int j = 0; j < contra->numCargo(); ++j) {
1545  Cargo *cj = &contra->GetCargo( j );
1546  if (ci->content == cj->content) {
1547  attack = true;
1548  break;
1549  }
1550  }
1551  }
1552  }
1553  }
1554  if (!attack) {
1555  Unit *un;
1557  (un = *i) != NULL;
1558  ++i)
1559  if (un->faction == own || un->faction == police || un->faction == police2) {
1560  if (un->Target() == parent || un->getRelation( parent ) < 0) {
1561  int parentCp = _Universe->whichPlayerStarship( parent );
1562  if (parentCp != -1)
1563  UniverseUtil::adjustRelationModifier( parentCp, fac, -ownrel-.1 );
1564  attack = true;
1565  break;
1566  }
1567  }
1568  }
1569  if (attack) {
1570  static std::string prison_system = vs_config->getVariable( "galaxy", "PrisonSystem", "Sol/Nu_Pheonix" );
1571  std::string psys = prison_system+"_"+fac;
1572  if (UnitUtil::getUnitSystemFile( parent ) != psys) {
1573  UnitUtil::JumpTo( parent, psys );
1575  0,
1576  "game",
1577  "all",
1578  parent->name
1579  +", you are under arrest! You will be taken to the prison system and will be tried for your crimes." );
1580  } else {
1581  Unit *un;
1582  Unit *owner = NULL;
1583  Unit *base = NULL;
1584  for (un_iter i = _Universe->activeStarSystem()->getUnitList().createIterator(); (un = *i) != NULL; ++i) {
1585  if (owner == NULL && un->getFlightgroup() && un->faction == own)
1586  if ( UnitUtil::isSignificant( un ) && ( !un->isJumppoint() ) )
1587  owner = un;
1588  if ( UnitUtil::isSignificant( un ) && ( !un->isJumppoint() ) )
1589  base = un;
1590  }
1591  if (owner == NULL)
1592  owner = base;
1593  if (owner) {
1594  Order *tmp = parent->aistate;
1595  parent->aistate = NULL;
1596  parent->PrimeOrders( new Orders::DockingOps( owner, tmp, true, true ) );
1597  arrested_list_do_not_dereference.insert( parent );
1598  for (int i = parent->numCargo()-1; i >= 0; --i)
1599  parent->RemoveCargo( i, parent->GetCargo( (unsigned int) i ).quantity, true );
1601  0,
1602  "game",
1603  "all",
1604  parent->name
1605  +
1606  ", your cargo has been confiscated and scanned. Here your ship will be kept until you complete your reintegration into society through our reprogramming pod(tm) system." );
1607  int whichCp = _Universe->whichPlayerStarship( parent );
1609  }
1610  }
1611  }
1612 }
void ChooseSubTargets ( Unit me)

Definition at line 1186 of file firekeyboard.cpp.

References Unit::getSubUnits(), UnitUtil::owner(), and Unit::Target().

Referenced by FireKeyboard::Execute().

1187 {
1188  Unit *parent = UnitUtil::owner( me->Target() );
1189  if (!parent)
1190  return;
1191  un_iter uniter = parent->getSubUnits();
1192  if ( parent == me->Target() ) {
1193  if ( !(*uniter) )
1194  return;
1195  me->Target( *uniter );
1196  return;
1197  }
1198  Unit *tUnit;
1199  for ( ; (tUnit=*uniter)!=NULL; ++uniter)
1200  if ( tUnit == me->Target() ) {
1201  ++uniter;
1202  tUnit = *uniter;
1203  break;
1204  }
1205  if (tUnit)
1206  me->Target( tUnit );
1207  else
1208  me->Target( parent );
1209 }
bool ChooseTargets ( Unit me,
bool(*)(Unit *, Unit *)  typeofunit,
bool  reverse 
)

Definition at line 1133 of file firekeyboard.cpp.

References _Universe, Universe::activeStarSystem(), UnitCollection::createIterator(), StarSystem::getUnitList(), VegaConfig::getVariable(), soundContainer::loadsound(), Network, soundContainer::playsound(), soundContainer::sound, Unit::Target(), NetClient::targetRequest(), vs_config, and Universe::whichPlayerStarship().

Referenced by FireKeyboard::Execute(), and ForceChangeTarget().

1134 {
1136  vector< Unit* > vec;
1137  Unit *target;
1138  for (un_iter iter = drawlist.createIterator(); (target=*iter)!=NULL; ++iter)
1139  vec.push_back( target );
1140  if (vec.size() == 0)
1141  return false;
1142  if (reverse)
1143  std::reverse( vec.begin(), vec.end() );
1144  std::vector< Unit* >::const_iterator veciter = std::find( vec.begin(), vec.end(), me->Target() );
1145  if ( veciter != vec.end() )
1146  ++veciter;
1147  int cur = 0;
1148  while (1) {
1149  while ( veciter != vec.end() ) {
1150  if ( ( (*veciter) != me ) && ( (*veciter)->GetHull() >= 0 ) && typeofunit( me, (*veciter) ) ) {
1151  me->Target( *veciter );
1152  if (Network != NULL) {
1153  int player = _Universe->whichPlayerStarship( me );
1154  if (player >= 0)
1155  Network[player].targetRequest( *veciter );
1156  }
1157  if ( (*veciter) != NULL ) {
1158  if (reverse) {
1159  static soundContainer foosound;
1160  if (foosound.sound < 0) {
1161  static string str = vs_config->getVariable( "cockpitaudio", "target", "vdu_b" );
1162  foosound.loadsound( str );
1163  }
1164  foosound.playsound();
1165  } else {
1166  static soundContainer foobersound;
1167  if (foobersound.sound < 0) {
1168  static string str = vs_config->getVariable( "cockpitaudio", "target_reverse", "vdu_a" );
1169  foobersound.loadsound( str );
1170  }
1171  foobersound.playsound();
1172  }
1173  }
1174  return true;
1175  }
1176  ++veciter;
1177  }
1178  ++cur;
1179  if (cur >= 2)
1180  break;
1181  veciter = vec.begin();
1182  }
1183  return true;
1184 }
static void DoDockingOps ( Unit parent,
Unit targ,
unsigned char  playa,
unsigned char  gender 
)
static

Definition at line 1392 of file firekeyboard.cpp.

References _Universe, abletodock(), Universe::activeStarSystem(), MessageCenter::add(), c, Order::Communicate(), UnitCollection::createIterator(), Unit::EndRequestClearance(), ExecuteRequestClearenceKey(), CommunicationMessage::fsm, Unit::getAIState(), FSM::GetFailDockNode(), FSM::GetUnDockNode(), StarSystem::getUnitList(), VegaConfig::getVariable(), UnitUtil::isCloseEnoughToDock(), UnitUtil::isDockableUnit(), mission, Mission::msgcenter, XMLSupport::parse_bool(), Unit::RequestClearance(), CommunicationMessage::SetCurrentState(), Unit::Target(), TryDock(), UnDockNow(), vectorOfKeyboardInput, and vs_config.

Referenced by FireKeyboard::Execute().

1393 {
1394  static int maxseverity = XMLSupport::parse_bool( vs_config->getVariable( "AI", "dock_to_area", "false" ) ) ? 2 : 1;
1395  Unit *endt = targ;
1396  bool wasdock = vectorOfKeyboardInput[playa].doc;
1397  if (vectorOfKeyboardInput[playa].doc) {
1398  bool isDone = false;
1399  if (targ) {
1400  for (int severity = 0; severity < maxseverity; ++severity) {
1401  targ->RequestClearance( parent );
1402  if ( ( isDone = TryDock( parent, targ, playa, severity ) ) != false ) {
1403  parent->EndRequestClearance( targ );
1404  break;
1405  } else {
1406  parent->EndRequestClearance( targ );
1407  }
1408  }
1409  }
1410  if (!isDone) {
1411  for (int severity = 0; severity < maxseverity && !isDone; ++severity)
1413  (targ = *u) != NULL && !isDone;
1414  ++u)
1415  //Let's make sure potentials are actually in range, and have
1416  //docking ports before we try to dock with them.
1417  if ( (targ != parent)
1418  && ( UnitUtil::isDockableUnit( targ ) )
1419  && ( UnitUtil::isCloseEnoughToDock( parent, targ ) ) ) {
1420  targ->RequestClearance( parent );
1421  if ( TryDock( parent, targ, playa, severity ) ) {
1422  parent->Target( targ );
1423  isDone = true;
1424  parent->EndRequestClearance( targ );
1425  break;
1426  } else {
1427  parent->EndRequestClearance( targ );
1428  }
1429  }
1430  }
1431  if (!isDone) {
1432  if (endt)
1433  ExecuteRequestClearenceKey( parent, endt );
1434  abletodock( 0 );
1435  }
1436  vectorOfKeyboardInput[playa].doc = false;
1437  }
1438  if (vectorOfKeyboardInput[playa].req && endt != NULL) {
1439  bool request = ExecuteRequestClearenceKey( parent, endt );
1440  if (!request) {
1441  mission->msgcenter->add( "game",
1442  "all",
1443  "[Computer] Cannot dock with insubstantidisabal object, target another object and retry." );
1444  abletodock( 0 );
1445  return;
1446  } else if (!wasdock) {
1447  abletodock( 1 );
1448  }
1449  vectorOfKeyboardInput[playa].req = false;
1450  }
1451  if (vectorOfKeyboardInput[playa].und && endt != NULL) {
1452  CommunicationMessage c( endt, parent, NULL, 0 );
1453  if ( UnDockNow( parent, endt ) ) {
1454  c.SetCurrentState( c.fsm->GetUnDockNode(), NULL, 0 );
1455  abletodock( 5 );
1456  } else {
1457  c.SetCurrentState( c.fsm->GetFailDockNode(), NULL, 0 );
1458  abletodock( 4 );
1459  }
1460  parent->getAIState()->Communicate( c );
1461  vectorOfKeyboardInput[playa].und = 0;
1462  }
1463 }
unsigned int DoSpeech ( Unit un,
Unit player_un,
const FSM::Node convNode 
)

Definition at line 199 of file aggressive.cpp.

References MessageCenter::add(), Unit::getFgSubnumber(), Unit::getFlightgroup(), Unit::getFullname(), FSM::Node::GetMessage(), Unit::getRelation(), GetRelationshipColor(), Unit::isUnit(), FSM::Node::messagedelta, mission, Mission::msgcenter, Flightgroup::name, Unit::name, PLANETPTR, and XMLSupport::tostring().

Referenced by FireKeyboard::DoSpeechAndAni(), FireKeyboard::Execute(), HelpOut(), LeadMe(), and FireKeyboard::ProcessCommMessage().

200 {
201  unsigned int dummy = 0;
202  string speech = node.GetMessage( dummy );
203  string myname( "[Static]" );
204  if (un != NULL) {
205  myname = un->isUnit() == PLANETPTR ? un->name : un->getFullname();
206  Flightgroup *fg = un->getFlightgroup();
207  if (fg && fg->name != "base" && fg->name != "Base")
208  myname = fg->name+" "+XMLSupport::tostring( un->getFgSubnumber() )+", "+un->getFullname();
209  else if (myname.length() == 0)
210  myname = un->name;
211  if (player_un != NULL) {
212  if (player_un == un) {
213  myname = std::string( "#0033FF" )+myname+"#000000";
214  } else {
215  float rel = un->getRelation( player_un );
216  myname = GetRelationshipColor( rel )+myname+"#000000";
217  }
218  }
219  }
220  mission->msgcenter->add( myname, "all", GetRelationshipColor( node.messagedelta*10 )+speech+"#000000" ); //multiply by 2 so colors are easier to tell
221  return dummy;
222 }
void Enslave ( Unit ,
bool   
)

Definition at line 317 of file unit_functions_generic.cpp.

References Unit::AddCargo(), Unit::CanAddCargo(), Cargo::content, Unit::GetCargo(), Cargo::GetCategory(), UniverseUtil::GetMasterPartList(), i, Unit::numCargo(), Cargo::quantity, and Unit::RemoveCargo().

Referenced by FireKeyboard::Execute().

318 {
319  unsigned int i;
320  vector< Cargo >ToBeChanged;
321  unsigned int numcargo = parent->numCargo();
322  for (i = numcargo-1; i >= 0; --i) {
323  Cargo *carg = &parent->GetCargo( i );
324  if (enslave) {
325  if (carg->GetCategory().find( "Passengers" ) != string::npos && carg->content != "Hitchhiker") {
326  ToBeChanged.push_back( *carg );
327  parent->RemoveCargo( i, carg->quantity, true );
328  }
329  } else if (carg->content == "Slaves" || carg->content == "Pilot") {
330  ToBeChanged.push_back( *carg );
331  parent->RemoveCargo( i, carg->quantity, true );
332  }
333  }
334  unsigned int dummy;
335  Cargo *newCarg = UniverseUtil::GetMasterPartList()->GetCargo( enslave ? "Slaves" : "Hitchhiker", dummy );
336  if (newCarg) {
337  Cargo slave = *newCarg;
338  for (i = 0; i < ToBeChanged.size(); ++i) {
339  slave.quantity = ToBeChanged[i].quantity;
340  while (parent->CanAddCargo( slave ) == false && (--slave.quantity) > 0) {}
341  if (slave.quantity)
342  if ( parent->CanAddCargo( slave ) )
343  parent->AddCargo( slave, true );
344  }
345  }
346 }
void ExamineWhenTargetKey ( )

Definition at line 152 of file main_loop.cpp.

References _Universe, Universe::AccessCockpit(), Cockpit::getVDUMode(), vs_options::switchToTargetModeOnKey, SwitchVDUTo(), VDU::TARGET, GFXMatrices::view, and VDU::VIEW.

Referenced by FireKeyboard::IncomingMissileTargetKey(), FireKeyboard::MissileTargetKey(), FireKeyboard::NearestBaseKey(), FireKeyboard::NearestDangerousHostileKey(), FireKeyboard::NearestFriendlyKey(), FireKeyboard::NearestHostileTargetKey(), FireKeyboard::NearestJumpKey(), FireKeyboard::NearestPlanetKey(), FireKeyboard::NearestTargetKey(), FireKeyboard::NearestTargetTurretKey(), FireKeyboard::PickTargetKey(), FireKeyboard::PickTargetTurretKey(), FireKeyboard::ReverseIncomingMissileTargetKey(), FireKeyboard::ReverseMissileTargetKey(), FireKeyboard::ReverseNearestTargetKey(), FireKeyboard::ReversePickTargetKey(), FireKeyboard::ReverseSigTargetKey(), FireKeyboard::ReverseTargetKey(), FireKeyboard::ReverseThreatTargetKey(), FireKeyboard::ReverseUnitTargetKey(), FireKeyboard::SigTargetKey(), FireKeyboard::SubUnitTargetKey(), FireKeyboard::TargetKey(), FireKeyboard::TargetTurretKey(), FireKeyboard::ThreatTargetKey(), FireKeyboard::ThreatTargetTurretKey(), and FireKeyboard::UnitTargetKey().

153 {
155  int view = 0;
156  int examine = 0;
157  for (; view < 2; ++view)
158  if (_Universe->AccessCockpit()->getVDUMode( view ) == VDU::VIEW)
159  break;
160  for (; examine < 2; ++examine)
161  if (_Universe->AccessCockpit()->getVDUMode( examine ) == VDU::TARGET)
162  break;
163  if ( (examine == 2) && (view == 2) )
165  }
166 }
static bool ExecuteRequestClearenceKey ( Unit parent,
Unit endt 
)
static

Definition at line 1375 of file firekeyboard.cpp.

References Unit::EnqueueAIFirst(), Unit::getRelation(), VegaConfig::getVariable(), Unit::graphicOptions, Unit::graphic_options::InWarp, XMLSupport::parse_float(), Unit::RequestClearance(), Vector, vs_config, and Unit::graphic_options::WarpRamping.

Referenced by DoDockingOps().

1376 {
1377  bool tmp = endt->RequestClearance( parent );
1378  if (endt->getRelation( parent ) >= 0) {
1379  if (endt->graphicOptions.InWarp)
1380  endt->graphicOptions.WarpRamping = 1;
1381  endt->graphicOptions.InWarp = 0;
1382  static float clearencetime = ( XMLSupport::parse_float( vs_config->getVariable( "general", "dockingtime", "20" ) ) );
1383  endt->EnqueueAIFirst( new Orders::ExecuteFor( new Orders::MatchVelocity( Vector( 0, 0, 0 ),
1384  Vector( 0, 0, 0 ),
1385  true,
1386  false,
1387  true ), clearencetime ) );
1388  }
1389  return tmp;
1390 }
static void ForceChangeTarget ( Unit parent)
static

Definition at line 1616 of file firekeyboard.cpp.

References ChooseTargets(), VegaConfig::getVariable(), XMLSupport::parse_bool(), TargAll(), Unit::Target(), TargNear(), TargUn(), and vs_config.

Referenced by FireKeyboard::Execute().

1617 {
1618  Unit *curtarg = parent->Target();
1619  ChooseTargets( parent, TargUn, false );
1620  static bool force_change_only_unit =
1621  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "target_null_if_no_unit", "false" ) );
1622  if (parent->Target() == curtarg) {
1623  if (force_change_only_unit) {
1624  parent->Target( NULL );
1625  } else {
1626  ChooseTargets( parent, TargNear, false );
1627  if (parent->Target() == curtarg)
1628  ChooseTargets( parent, TargAll, false );
1629  }
1630  }
1631 }
static FIREKEYBOARDTYPE& g ( )
static

Definition at line 141 of file firekeyboard.cpp.

References _Universe, Universe::CurrentCockpit(), int, MAX_JOYSTICKS, and vectorOfKeyboardInput.

Referenced by FireKeyboard::CloakKey(), FireKeyboard::DockKey(), FireKeyboard::ECMKey(), FireKeyboard::EjectCargoKey(), FireKeyboard::EjectDockKey(), FireKeyboard::EjectKey(), FireKeyboard::EjectNonMissionCargoKey(), FireKeyboard::EnslaveKey(), FireKeyboard::FireKey(), FireKeyboard::FreeSlaveKey(), FireKeyboard::IncomingMissileTargetKey(), FireKeyboard::LockKey(), FireKeyboard::MisSelKey(), FireKeyboard::MissileKey(), FireKeyboard::MissileTargetKey(), FireKeyboard::MissionTargetKey(), FireKeyboard::NearestBaseKey(), FireKeyboard::NearestDangerousHostileKey(), FireKeyboard::NearestFriendlyKey(), FireKeyboard::NearestHostileTargetKey(), FireKeyboard::NearestJumpKey(), FireKeyboard::NearestPlanetKey(), FireKeyboard::NearestTargetKey(), FireKeyboard::NearestTargetTurretKey(), FireKeyboard::PickTargetKey(), FireKeyboard::PickTargetTurretKey(), FireKeyboard::PressComm10Key(), FireKeyboard::PressComm1Key(), FireKeyboard::PressComm2Key(), FireKeyboard::PressComm3Key(), FireKeyboard::PressComm4Key(), FireKeyboard::PressComm5Key(), FireKeyboard::PressComm6Key(), FireKeyboard::PressComm7Key(), FireKeyboard::PressComm8Key(), FireKeyboard::PressComm9Key(), FireKeyboard::RequestClearenceKey(), FireKeyboard::RestoreTarget10Key(), FireKeyboard::RestoreTarget1Key(), FireKeyboard::RestoreTarget2Key(), FireKeyboard::RestoreTarget3Key(), FireKeyboard::RestoreTarget4Key(), FireKeyboard::RestoreTarget5Key(), FireKeyboard::RestoreTarget6Key(), FireKeyboard::RestoreTarget7Key(), FireKeyboard::RestoreTarget8Key(), FireKeyboard::RestoreTarget9Key(), FireKeyboard::ReverseIncomingMissileTargetKey(), FireKeyboard::ReverseMisSelKey(), FireKeyboard::ReverseMissileTargetKey(), FireKeyboard::ReverseMissionTargetKey(), FireKeyboard::ReverseNearestTargetKey(), FireKeyboard::ReversePickTargetKey(), FireKeyboard::ReverseSigTargetKey(), FireKeyboard::ReverseTargetKey(), FireKeyboard::ReverseThreatTargetKey(), FireKeyboard::ReverseUnitTargetKey(), FireKeyboard::ReverseWeapSelKey(), FireKeyboard::SaveTarget10Key(), FireKeyboard::SaveTarget1Key(), FireKeyboard::SaveTarget2Key(), FireKeyboard::SaveTarget3Key(), FireKeyboard::SaveTarget4Key(), FireKeyboard::SaveTarget5Key(), FireKeyboard::SaveTarget6Key(), FireKeyboard::SaveTarget7Key(), FireKeyboard::SaveTarget8Key(), FireKeyboard::SaveTarget9Key(), FireKeyboard::SetShieldsOff(), FireKeyboard::SetShieldsOneThird(), FireKeyboard::SetShieldsTwoThird(), FireKeyboard::SigTargetKey(), FireKeyboard::SubUnitTargetKey(), FireKeyboard::TargetKey(), FireKeyboard::TargetTurretKey(), FireKeyboard::ThreatTargetKey(), FireKeyboard::ThreatTargetTurretKey(), FireKeyboard::ToggleAnimation(), FireKeyboard::ToggleAutotracking(), FireKeyboard::ToggleGlow(), FireKeyboard::TogglePause(), FireKeyboard::ToggleWarpDrive(), FireKeyboard::TurretAIOff(), FireKeyboard::TurretAIOn(), FireKeyboard::TurretFireAtWill(), FireKeyboard::UnDockKey(), FireKeyboard::UnitTargetKey(), and FireKeyboard::WeapSelKey().

142 {
143  while (vectorOfKeyboardInput.size() <= (unsigned int) _Universe->CurrentCockpit() || vectorOfKeyboardInput.size()
144  <= (unsigned int) MAX_JOYSTICKS)
147 }
bool getNearestTargetUnit ( Unit me,
int  iType 
)

Definition at line 1075 of file firekeyboard.cpp.

References _Universe, Universe::activeStarSystem(), UnitCollection::createIterator(), UnitUtil::getFlightgroupName(), StarSystem::getUnitList(), i, Unit::InRange(), Unit::isEnemy(), Magnitude(), Network, Unit::Position(), QVector, Unit::Target(), NetClient::targetRequest(), UNITPTR, and Universe::whichPlayerStarship().

Referenced by FireKeyboard::Execute().

1076 {
1077  QVector pos( me->Position() );
1078  Unit *un = NULL;
1079  Unit *targ = NULL;
1080  double minrange = FLT_MAX;
1081  for (un_iter i = _Universe->activeStarSystem()->getUnitList().createIterator(); ( un = (*i) ); ++i) {
1082  if (un == me)
1083  continue;
1084  if (un->hull < 0)
1085  continue;
1086  if ( !( me->InRange( un, true, false ) )
1087  || !( me->InRange( un, true, true ) ) )
1088  continue;
1089  if ( (iType == 0)
1090  && ( (un->isUnit() != UNITPTR)
1091  || !me->isEnemy( un ) ) )
1092  continue;
1093  if ( (iType == 1)
1094  && ( (un->isUnit() != UNITPTR)
1095  || ( !me->isEnemy( un )
1096  && (un->Target() != me) ) ) )
1097  continue;
1098  if ( (iType == 2)
1099  && ( (un->isUnit() != UNITPTR)
1100  || me->isEnemy( un )
1101  || (UnitUtil::getFlightgroupName( un ) == "Base") ) )
1102  continue;
1103  if ( (iType == 3)
1104  && (UnitUtil::getFlightgroupName( un ) != "Base") )
1105  continue;
1106  if ( (iType == 4)
1107  && ( ( !un->isPlanet() )
1108  || ( un->isJumppoint() ) ) )
1109  continue;
1110  if ( (iType == 5)
1111  && ( !un->isJumppoint() ) )
1112  continue;
1113  double temp = (un->Position()-pos).Magnitude();
1114  if (targ == NULL) {
1115  targ = un;
1116  minrange = temp;
1117  } else if (temp < minrange) {
1118  targ = un;
1119  minrange = temp;
1120  }
1121  }
1122  if (targ == NULL)
1123  return false;
1124  me->Target( targ );
1125  if (Network != NULL) {
1126  int player = _Universe->whichPlayerStarship( me );
1127  if (player >= 0)
1128  Network[player].targetRequest( targ );
1129  }
1130  return true;
1131 }
static CommunicationMessage* GetTargetMessageQueue ( Unit targ,
std::list< CommunicationMessage > &  messagequeue 
)
static

Definition at line 1518 of file firekeyboard.cpp.

References i.

Referenced by FireKeyboard::Execute().

1519 {
1520  CommunicationMessage *mymsg = NULL;
1521  for (list< CommunicationMessage >::iterator i = messagequeue.begin(); i != messagequeue.end(); i++)
1522  if ( (*i).sender.GetUnit() == targ ) {
1523  mymsg = &(*i);
1524  break;
1525  }
1526  return mymsg;
1527 }
Unit* GetThreat ( Unit par,
Unit leader 
)

Definition at line 574 of file aggressive.cpp.

References _Universe, Universe::activeStarSystem(), UnitCollection::createIterator(), d, Unit::getRelation(), StarSystem::getUnitList(), Magnitude(), Unit::Position(), and Unit::Target().

Referenced by HelpOut(), and Orders::AggressiveAI::ProcessCurrentFgDirective().

575 {
576  Unit *th = NULL;
577  Unit *un = NULL;
578  bool targetted = false;
579  float mindist = FLT_MAX;
581  (un = *ui);
582  ++ui)
583  if (parent->getRelation( un ) < 0) {
584  float d = ( un->Position()-leader->Position() ).Magnitude();
585  bool thistargetted = (un->Target() == leader);
586  if ( !th || (thistargetted && !targetted) || ( ( thistargetted || (!targetted) ) && d < mindist ) ) {
587  th = un;
588  targetted = thistargetted;
589  mindist = d;
590  }
591  }
592  return th;
593 }
Unit* getTopLevelOwner ( )

Definition at line 320 of file star_system_generic.cpp.

Referenced by Radar::CollectRadarTracks::acquire(), FireKeyboard::Execute(), UnitUtil::getPhysicsPriority(), UnitUtil::orbit(), and TargUn().

321 {
322  return (Unit*) 0x31337; //FIXME How about telling us a little story behind this function? --chuck_starchaser
323 }
void HelpOut ( bool  crit,
std::string  conv 
)

Definition at line 785 of file firekeyboard.cpp.

References _Universe, Universe::AccessCockpit(), Universe::activeStarSystem(), c, Order::Communicate(), UnitCollection::createIterator(), DoSpeech(), Unit::faction, CommunicationMessage::fsm, Unit::getAIState(), UnitUtil::getFactionRelation(), FSM::GetNoNode(), Cockpit::GetParent(), GetThreat(), StarSystem::getUnitList(), FSM::GetYesNode(), FSM::Node::MakeNode(), CommunicationMessage::SetCurrentState(), and Unit::Target().

Referenced by FireKeyboard::HelpMeOutCrit(), and FireKeyboard::HelpMeOutFaction().

786 {
788  if (un) {
789  Unit *par = NULL;
790  DoSpeech( un, NULL, FSM::Node::MakeNode( conv, .1 ) );
792  ( par = (*ui) );
793  ++ui)
794  if ( (crit && UnitUtil::getFactionRelation( par, un ) > 0) || par->faction == un->faction ) {
795  Unit *threat = GetThreat( par, un );
796  CommunicationMessage c( par, un, NULL, 0 );
797  if (threat) {
798  par->Target( threat );
799  c.SetCurrentState( c.fsm->GetYesNode(), NULL, 0 );
800  } else {
801  c.SetCurrentState( c.fsm->GetNoNode(), NULL, 0 );
802  }
803  Order *o = un->getAIState();
804  if (o)
805  o->Communicate( c );
806  }
807  }
808 }
static bool isNotTurretOwner ( Unit parent,
Unit un 
)
static

Definition at line 961 of file firekeyboard.cpp.

References Unit::isSubUnit(), and Unit::owner.

Referenced by TargAll(), TargMissile(), TargNear(), TargSig(), and TargUn().

962 {
963  return parent->isSubUnit() == false || un != parent->owner;
964 }
void LeadMe ( Unit un,
string  directive,
string  speech,
bool  changetarget 
)

Definition at line 224 of file aggressive.cpp.

References _Universe, Universe::AccessCockpit(), Flightgroup::directive, DoSpeech(), Unit::getFlightgroup(), Cockpit::GetParent(), UnitContainer::GetUnit(), i, Universe::isPlayerStarship(), Flightgroup::leader, FSM::Node::MakeNode(), Universe::numPlayers(), UnitContainer::SetUnit(), Flightgroup::target, and Unit::Target().

Referenced by FireKeyboard::AttackTarget(), FireKeyboard::BreakFormation(), FireKeyboard::DefendTarget(), FireKeyboard::DockTarget(), FireKeyboard::DockWithMe(), FireKeyboard::EjectKey(), FireKeyboard::FormUp(), FireKeyboard::HelpMeOut(), FireKeyboard::HoldPosition(), LeadMe(), and Orders::AggressiveAI::ReCommandWing().

225 {
226  if (un != NULL) {
227  for (unsigned int i = 0; i < _Universe->numPlayers(); i++) {
228  Unit *pun = _Universe->AccessCockpit( i )->GetParent();
229  if (pun)
230  if ( pun->getFlightgroup() == un->getFlightgroup() )
231  DoSpeech( un, pun, FSM::Node::MakeNode( speech, .1 ) );
232  }
233  Flightgroup *fg = un->getFlightgroup();
234  if (fg) {
235  if (fg->leader.GetUnit() != un)
236  if ( ( !_Universe->isPlayerStarship( fg->leader.GetUnit() ) ) || _Universe->isPlayerStarship( un ) )
237  fg->leader.SetUnit( un );
238  fg->directive = directive;
239  if (changetarget)
240  fg->target.SetUnit( un->Target() );
241  if ( (directive == "") )
242  fg->target.SetUnit( NULL );
243  }
244  }
245 }
static void LeadMe ( string  directive,
string  speech,
bool  changetarget 
)
static

Definition at line 416 of file firekeyboard.cpp.

References _Universe, Universe::AccessCockpit(), Cockpit::GetParent(), and LeadMe().

417 {
419  if (un) LeadMe( un, directive, speech, changetarget );
420 }
static void MyFunction ( )
static

Definition at line 1476 of file firekeyboard.cpp.

References _Universe, Universe::AccessCockpit(), VegaConfig::getVariable(), Cockpit::SetCommAnimation(), and vs_config.

Referenced by FireKeyboard::ProcessCommMessage().

1477 {
1478  //quit it--he's dead all ready
1479  static string comm_static = vs_config->getVariable( "graphics", "comm_static", "static.ani" );
1480  //dead dead dead dead
1481  static Animation Statuc( comm_static.c_str() );
1482  //yep really dead
1483  _Universe->AccessCockpit()->SetCommAnimation( &Statuc, NULL );
1484 }
void PowerDownShield ( Shield shield,
float  howmuch 
)

Definition at line 454 of file cockpit_generic.cpp.

References Shield::number, Shield::shield2fb, Shield::shield4fbrl, and Shield::shield8.

Referenced by FireKeyboard::Execute(), and Cockpit::Update().

455 {
456  switch (shield->number)
457  {
458  case 2:
459  if (shield->shield2fb.front/howmuch > shield->shield2fb.frontmax)
460  shield->shield2fb.front = shield->shield2fb.frontmax*howmuch;
461  if (shield->shield2fb.back/howmuch > shield->shield2fb.backmax)
462  shield->shield2fb.back = shield->shield2fb.backmax*howmuch;
463  break;
464  case 4:
465  if (shield->shield4fbrl.front/howmuch > shield->shield4fbrl.frontmax)
466  shield->shield4fbrl.front = shield->shield4fbrl.frontmax*howmuch;
467  if (shield->shield4fbrl.right/howmuch > shield->shield4fbrl.rightmax)
468  shield->shield4fbrl.right = shield->shield4fbrl.rightmax*howmuch;
469  if (shield->shield4fbrl.left/howmuch > shield->shield4fbrl.leftmax)
470  shield->shield4fbrl.left = shield->shield4fbrl.leftmax*howmuch;
471  if (shield->shield4fbrl.back/howmuch > shield->shield4fbrl.backmax)
472  shield->shield4fbrl.back = shield->shield4fbrl.backmax*howmuch;
473  break;
474  case 8:
475  if (shield->shield8.frontlefttop/howmuch > shield->shield8.frontlefttopmax)
476  shield->shield8.frontlefttop = shield->shield8.frontlefttopmax*howmuch;
477  if (shield->shield8.frontleftbottom/howmuch > shield->shield8.frontleftbottommax)
478  shield->shield8.frontleftbottom = shield->shield8.frontleftbottommax*howmuch;
479  if (shield->shield8.frontrighttop/howmuch > shield->shield8.frontrighttopmax)
480  shield->shield8.frontrighttop = shield->shield8.frontrighttopmax*howmuch;
481  if (shield->shield8.frontrightbottom/howmuch > shield->shield8.frontrightbottommax)
482  shield->shield8.frontrightbottom = shield->shield8.frontrightbottommax*howmuch;
483  if (shield->shield8.backlefttop/howmuch > shield->shield8.backlefttopmax)
484  shield->shield8.backlefttop = shield->shield8.backlefttopmax*howmuch;
485  if (shield->shield8.backleftbottom/howmuch > shield->shield8.backleftbottommax)
486  shield->shield8.backleftbottom = shield->shield8.backleftbottommax*howmuch;
487  if (shield->shield8.backrighttop/howmuch > shield->shield8.backrighttopmax)
488  shield->shield8.backrighttop = shield->shield8.backrighttopmax*howmuch;
489  if (shield->shield8.backrightbottom/howmuch > shield->shield8.backrightbottommax)
490  shield->shield8.backrightbottom = shield->shield8.backrightbottommax*howmuch;
491  break;
492  default:
493  break;
494  }
495 }
int SelectDockPort ( Unit utdw,
Unit parent 
)

Definition at line 110 of file docking.cpp.

111 {
112  const vector< DockingPorts >& dp = utdw->DockingPortLocations();
113  float dist = FLT_MAX;
114  int num = -1;
115  for (unsigned int i = 0; i < dp.size(); ++i)
116  if (!dp[i].IsOccupied()) {
117  Vector rez = Transform( utdw->GetTransformation(), dp[i].GetPosition() );
118  float wdist = ( rez - parent->Position() ).MagnitudeSquared();
119  if (wdist < dist) {
120  num = i;
121  dist = wdist;
122  }
123  }
124  return num;
125 }
static bool SuperDock ( Unit parent,
Unit target 
)
static

Definition at line 1321 of file firekeyboard.cpp.

References UnitImages< BOGUS >::dockingports, Unit::ForceDock(), Unit::GetImageInformation(), i, UnitUtil::isCloseEnoughToDock(), and UnitUtil::isDockableUnit().

Referenced by TryDock().

1322 {
1323  if ( UnitUtil::isCloseEnoughToDock( parent, target ) ) {
1324  if ( UnitUtil::isDockableUnit( target ) ) {
1325  for (unsigned int i = 0; i < target->GetImageInformation().dockingports.size(); ++i)
1326  if (!target->GetImageInformation().dockingports[i].IsOccupied())
1327  return parent->ForceDock( target, i ) != 0;
1328  }
1329  }
1330  return false;
1331 }
bool TargAll ( Unit me,
Unit target 
)

Definition at line 979 of file firekeyboard.cpp.

References VegaConfig::getVariable(), Unit::InRange(), isNotTurretOwner(), UnitUtil::isSun(), XMLSupport::parse_bool(), and vs_config.

Referenced by FireKeyboard::Execute(), ForceChangeTarget(), TargFront(), TargNear(), and TargThreat().

980 {
981  static bool can_target_sun = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "can_target_sun", "false" ) );
982  return ( me->InRange( target, true,
983  false )
984  || me->InRange( target, true, true ) ) && ( can_target_sun || !UnitUtil::isSun( target ) ) && isNotTurretOwner(
985  me,
986  target );
987 }
bool TargFront ( Unit me,
Unit target 
)

Definition at line 1028 of file firekeyboard.cpp.

References Unit::Position(), QVector, Unit::rSize(), TargAll(), Unit::ToLocalCoordinates(), and Vector.

Referenced by FireKeyboard::Execute().

1029 {
1030  if ( !TargAll( me, target ) )
1031  return false;
1032  QVector delta( target->Position()-me->Position() );
1033  double mm = delta.Magnitude();
1034  double tempmm = mm-target->rSize();
1035  if (tempmm > 0.0001)
1036  if ( (me->ToLocalCoordinates( Vector( delta.i, delta.j, delta.k ) ).k/tempmm) > .995 )
1037  return true;
1038  return false;
1039 }
bool TargIncomingMissile ( Unit me,
Unit target 
)

Definition at line 1022 of file firekeyboard.cpp.

References _Universe, Universe::AccessCockpit(), Cockpit::GetSaveParent(), Unit::isSubUnit(), Unit::Target(), and TargMissile().

Referenced by FireKeyboard::Execute().

1023 {
1024  Unit *tt = target->Target();
1025  return TargMissile( me, target ) && ( tt == me || ( me->isSubUnit() && tt == _Universe->AccessCockpit()->GetSaveParent() ) );
1026 }
bool TargMissile ( Unit me,
Unit target 
)

Definition at line 1017 of file firekeyboard.cpp.

References Unit::InRange(), isNotTurretOwner(), Unit::isUnit(), and MISSILEPTR.

Referenced by FireKeyboard::Execute(), and TargIncomingMissile().

1018 {
1019  return me->InRange( target, true, false ) && (target->isUnit() == MISSILEPTR) && isNotTurretOwner( me, target );
1020 }
bool TargMission ( Unit me,
Unit target 
)

Definition at line 966 of file firekeyboard.cpp.

References active_missions, and i.

Referenced by FireKeyboard::Execute(), and TargSig().

967 {
968  for (unsigned int i = 0; i < active_missions.size(); ++i)
969  if (active_missions[i]->runtime.pymissions) {
970  vector< UnitContainer* > *relevant = &active_missions[i]->runtime.pymissions->relevant_units;
971  vector< UnitContainer* >::iterator ir = relevant->begin();
972  vector< UnitContainer* >::iterator ie = relevant->end();
973  for (; ir != ie; ++ir)
974  if (**ir == target) return true;
975  }
976  return false;
977 }
bool TargNear ( Unit me,
Unit target 
)

Definition at line 1054 of file firekeyboard.cpp.

References Unit::getRelation(), VegaConfig::getVariable(), isNotTurretOwner(), UnitUtil::isSun(), Unit::isUnit(), MISSILEPTR, XMLSupport::parse_bool(), TargAll(), TargThreat(), and vs_config.

Referenced by FireKeyboard::Execute(), and ForceChangeTarget().

1055 {
1056  static bool can_target_sun = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "can_target_sun", "false" ) );
1057  return (me->getRelation( target ) < 0
1058  || TargThreat( me,
1059  target )
1060  || target->getRelation( me ) < 0)
1061  && TargAll( me,
1062  target ) && target->isUnit() != MISSILEPTR
1063  && ( can_target_sun || !UnitUtil::isSun( target ) ) && isNotTurretOwner( me,
1064  target );
1065 }
bool TargSig ( Unit me,
Unit target 
)

Definition at line 989 of file firekeyboard.cpp.

References ASTEROIDPTR, VegaConfig::getVariable(), Unit::InRange(), isNotTurretOwner(), UnitUtil::isSignificant(), Unit::isUnit(), Unit::name, XMLSupport::parse_bool(), TargMission(), and vs_config.

Referenced by FireKeyboard::Execute().

990 {
991  static bool can_target_asteroid = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "can_target_asteroid", "true" ) );
992 
993  bool ret =
994  me->InRange( target, false,
995  true ) && ( UnitUtil::isSignificant( target ) || TargMission( me, target ) ) && isNotTurretOwner(
996  me,
997  target );
998  if (can_target_asteroid == false)
999  if (target->isUnit() == ASTEROIDPTR || target->name.get().find( "Asteroid" ) == 0)
1000  ret = false;
1001  return ret;
1002 }
bool TargThreat ( Unit me,
Unit target 
)

Definition at line 1041 of file firekeyboard.cpp.

References Unit::isUnit(), MISSILEPTR, TargAll(), Unit::Target(), and Unit::Threat().

Referenced by FireKeyboard::Execute(), and TargNear().

1042 {
1043  if ( !TargAll( me, target ) )
1044  return false;
1045  if (target->isUnit() == MISSILEPTR)
1046  return false;
1047  if (target->Target() == me)
1048  return true;
1049  if (me->Threat() == target)
1050  return true;
1051  return false;
1052 }
bool TargUn ( Unit me,
Unit target 
)

Definition at line 1006 of file firekeyboard.cpp.

References ENHANCEMENTPTR, Unit::faction, getTopLevelOwner(), FactionUtil::GetUpgradeFaction(), VegaConfig::getVariable(), Unit::InRange(), isNotTurretOwner(), Unit::isUnit(), Unit::owner, XMLSupport::parse_bool(), UNITPTR, up, and vs_config.

Referenced by FireKeyboard::Execute(), and ForceChangeTarget().

1007 {
1008  static bool can_target_cargo = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "can_target_cargo", "false" ) );
1010  return me->InRange( target, true,
1011  false )
1012  && (target->isUnit() == UNITPTR
1013  || target->isUnit() == ENHANCEMENTPTR) && getTopLevelOwner() != target->owner
1014  && (can_target_cargo || target->faction != up) && isNotTurretOwner( me, target );
1015 }
bool toggle_pause ( )

Keyboard parsing Parses keyboard commands

Definition at line 113 of file lin_time.cpp.

References setTimeCompression().

Referenced by FireKeyboard::Execute().

114 {
115  static bool paused = false;
116  if (paused)
117  {
119  paused = false;
120  }
121  else
122  {
123  setTimeCompression(.0000001);
124  paused = true;
125  }
126  return paused;
127 }
static bool TryDock ( Unit parent,
Unit targ,
unsigned char  playa,
int  severity 
)
static

Definition at line 1333 of file firekeyboard.cpp.

References abletodock(), c, Order::Communicate(), Unit::Dock(), CommunicationMessage::fsm, Unit::getAIState(), Pilot::getCommFaces(), Unit::GetComputerData(), FSM::GetDockNode(), UnitUtil::getFlightgroupName(), FSM::GetNoNode(), Unit::getRelation(), FSM::GetUnDockNode(), VegaConfig::getVariable(), Unit::graphicOptions, Unit::graphic_options::InWarp, XMLSupport::parse_bool(), XMLSupport::parse_float(), Unit::pilot, CommunicationMessage::SetCurrentState(), SuperDock(), Unit::Computer::target, UnDockNow(), Unit::UpgradeInterface(), and vs_config.

Referenced by DoDockingOps().

1334 {
1335  static float min_docking_relationship =
1336  XMLSupport::parse_float( vs_config->getVariable( "AI", "min_docking_relationship", "-.002" ) );
1337  static bool can_dock_to_enemy_base =
1338  XMLSupport::parse_bool( vs_config->getVariable( "AI", "can_dock_to_enemy_base", "true" ) );
1339  static bool nojumpinSPEC = XMLSupport::parse_bool( vs_config->getVariable( "physics", "noSPECJUMP", "true" ) );
1340  bool SPEC_interference = targ && parent && nojumpinSPEC
1341  && (targ->graphicOptions.InWarp || parent->graphicOptions.InWarp);
1342  unsigned char gender = 0;
1343  vector< Animation* > *anim = NULL;
1344  if (SPEC_interference)
1345  //FIXME js_NUDGE -- need some indicator of non-interaction because one or both objects are in SPEC.
1346  return false;
1347  anim = targ->pilot->getCommFaces( gender );
1348 
1349  bool isDone = false;
1350  if ( targ->getRelation( parent ) >= min_docking_relationship
1351  || (can_dock_to_enemy_base && UnitUtil::getFlightgroupName( targ ) == "Base") ) {
1352  bool hasDock = severity == 0 ? parent->Dock( targ ) : SuperDock( parent, targ );
1353 
1354  CommunicationMessage c( targ, parent, anim, gender );
1355  if (hasDock) {
1356  isDone = true;
1357  c.SetCurrentState( c.fsm->GetDockNode(), anim, gender );
1358  abletodock( 3 );
1359  if ( parent->getAIState() ) parent->getAIState()->Communicate( c );
1360  parent->UpgradeInterface( targ );
1361  } else if ( UnDockNow( parent, targ ) ) {
1362  isDone = true;
1363  c.SetCurrentState( c.fsm->GetUnDockNode(), anim, gender );
1364  if ( parent->getAIState() ) parent->getAIState()->Communicate( c );
1365  abletodock( 5 );
1366  }
1367  } else if (parent->GetComputerData().target == targ) {
1368  CommunicationMessage c( targ, parent, anim, gender );
1369  c.SetCurrentState( c.fsm->GetNoNode(), anim, gender );
1370  if ( parent->getAIState() ) parent->getAIState()->Communicate( c );
1371  }
1372  return isDone;
1373 }
static bool UnDockNow ( Unit me,
Unit targ 
)
static

Definition at line 1232 of file firekeyboard.cpp.

References _Universe, Universe::activeStarSystem(), UnitCollection::createIterator(), StarSystem::getUnitList(), i, Unit::isDocked(), and Unit::UnDock().

Referenced by DoDockingOps(), and TryDock().

1233 {
1234  bool ret = false;
1235  Unit *un;
1237  (un = *i) != NULL;
1238  ++i)
1239  if ( un->isDocked( me ) )
1240  if ( me->UnDock( un ) )
1241  ret = true;
1242  return ret;
1243 }

Variable Documentation

std::set< Unit* > arrested_list_do_not_dereference

Definition at line 5826 of file unit_generic.cpp.

Referenced by Unit::ForceDock().

const unsigned int NUMCOMMKEYS = 10

Definition at line 45 of file firekeyboard.cpp.

Referenced by FireKeyboard::Execute().

std::vector< FIREKEYBOARDTYPE > vectorOfKeyboardInput
static