37 this->autotrackingtoggle = 1;
38 this->cloaktoggle =
true;
41 gunspeed = gunrange = .0001;
42 refresh_target =
true;
64 blinkleftkey = blinkrightkey = headlightkey = sirenkey =
UP;
169 if (
g().shieldpowerstate != pow)
186 if (
g().shieldpowerstate != pow)
203 if (
g().shieldpowerstate != pow)
414 extern void LeadMe(
Unit *un,
string directive,
string speech,
bool changetarget );
416 static void LeadMe(
string directive,
string speech,
bool changetarget )
419 if (un)
LeadMe( un, directive, speech, changetarget );
451 LeadMe(
"",
"I am ejecting! Record the current location of my ship.",
false );
452 LeadMe(
"e",
"Then get over here and pick me up!",
false );
541 if (
g().firekey ==
DOWN && k ==
UP)
543 if (k ==
UP &&
g().firekey ==
RELEASE) {}
else {
552 if (
g().targetkey !=
PRESS)
562 if (
g().picktargetkey !=
PRESS)
572 if (
g().missiletargetkey !=
PRESS)
580 if (
g().incomingmissiletargetkey !=
PRESS)
588 if (
g().rmissiletargetkey !=
PRESS)
596 if (
g().rincomingmissiletargetkey !=
PRESS)
604 if (
g().neartargetkey !=
PRESS)
612 if (
g().subtargetkey !=
PRESS)
620 if (
g().threattargetkey !=
PRESS)
628 if (
g().targetukey !=
PRESS)
636 if (
g().targetskey !=
PRESS)
644 if (
g().rtargetkey !=
PRESS)
654 if (
g().rpicktargetkey !=
PRESS)
664 if (
g().rneartargetkey !=
PRESS)
672 if (
g().rthreattargetkey !=
PRESS)
680 if (
g().rtargetukey !=
PRESS)
688 if (
g().rtargetskey !=
PRESS)
696 if (
g().nearesthostilekey !=
PRESS)
704 if (
g().nearestdangeroushostilekey !=
PRESS)
712 if (
g().nearestfriendlykey !=
PRESS)
720 if (
g().nearestbasekey !=
PRESS)
728 if (
g().nearestplanetkey !=
PRESS)
736 if (
g().nearestjumpkey !=
PRESS)
744 if (
g().togglepausekey !=
PRESS)
752 g().blinkleftkey = k;
754 g().blinkleftkey = k;
760 g().blinkrightkey = k;
762 g().blinkrightkey = k;
776 g().headlightkey = k;
778 g().headlightkey = k;
837 LeadMe(
"k",
"Attack my target!",
true );
843 LeadMe(
"h",
"Help me out!",
false );
849 HelpOut(
false,
"Help me out! I need critical assistance!" );
855 HelpOut(
true,
"Help me out! Systems going critical!" );
861 LeadMe(
"l",
"Get in front of me and prepare to be tractored in.",
false );
867 LeadMe(
"p",
"Defend my target!",
true );
872 LeadMe(
"t",
"Dock at my target!",
true );
878 LeadMe(
"s",
"Hold Position!",
true );
883 LeadMe(
"f",
"Form on my wing.",
false );
889 LeadMe(
"",
"Break formation!",
false );
891 LeadMe(
"b",
"Pick a target and open fire!",
false );
897 if (
g().turrettargetkey !=
PRESS)
907 if (
g().pickturrettargetkey !=
PRESS)
917 if (
g().nearturrettargetkey !=
PRESS)
925 if (
g().threatturrettargetkey !=
PRESS)
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;
982 return ( me->
InRange( target,
true,
998 if (can_target_asteroid ==
false)
1010 return me->
InRange( target,
true,
1033 double mm = delta.Magnitude();
1034 double tempmm = mm-target->
rSize();
1035 if (tempmm > 0.0001)
1047 if (target->
Target() == me)
1049 if (me->
Threat() == target)
1080 double minrange = FLT_MAX;
1086 if ( !( me->
InRange( un,
true,
false ) )
1087 || !( me->
InRange( un,
true,
true ) ) )
1090 && ( (un->isUnit() !=
UNITPTR)
1094 && ( (un->isUnit() !=
UNITPTR)
1096 && (un->Target() != me) ) ) )
1099 && ( (un->isUnit() !=
UNITPTR)
1107 && ( ( !un->isPlanet() )
1108 || ( un->isJumppoint() ) ) )
1111 && ( !un->isJumppoint() ) )
1113 double temp = (un->Position()-pos).
Magnitude();
1117 }
else if (temp < minrange) {
1136 vector< Unit* > vec;
1139 vec.push_back( target );
1140 if (vec.size() == 0)
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() )
1149 while ( veciter != vec.end() ) {
1150 if ( ( (*veciter) != me ) && ( (*veciter)->GetHull() >= 0 ) && typeofunit( me, (*veciter) ) ) {
1157 if ( (*veciter) != NULL ) {
1160 if (foosound.
sound < 0) {
1167 if (foobersound.
sound < 0) {
1181 veciter = vec.begin();
1192 if ( parent == me->
Target() ) {
1199 for ( ; (tUnit=*uniter)!=NULL; ++uniter)
1200 if ( tUnit == me->
Target() ) {
1219 bool FireKeyboard::ShouldFire(
Unit *targ )
1221 float dist = FLT_MAX;
1223 if (gunspeed == .0001)
1229 return dist < .8 && angle > 1;
1255 if (reqsound.
sound == -2) {
1256 static string str =
vs_config->
getVariable(
"cockpitaudio",
"undocking_complete",
"undocking_complete" );
1265 if (reqsound.
sound == -2) {
1266 static string str =
vs_config->
getVariable(
"cockpitaudio",
"undocking_failed",
"undocking_failed" );
1275 static string otherstr =
vs_config->
getVariable(
"audio",
"automatic_docking_zone",
"automatic_landing_zone.wav" );
1276 if (otherstr !=
"" && rand() < RAND_MAX/2) {
1280 if (reqsound.
sound == -2) {
1281 static string str =
vs_config->
getVariable(
"cockpitaudio",
"docking_complete",
"docking_complete" );
1291 if (reqsound.
sound == -2) {
1292 static string str =
vs_config->
getVariable(
"cockpitaudio",
"docking_failed",
"docking_failed" );
1301 if (reqsound.
sound == -2) {
1302 static string str =
vs_config->
getVariable(
"cockpitaudio",
"docking_granted",
"request_granted" );
1311 if (reqsound.
sound == -2) {
1312 static string str =
vs_config->
getVariable(
"cockpitaudio",
"docking_denied",
"request_denied" );
1335 static float min_docking_relationship =
1337 static bool can_dock_to_enemy_base =
1340 bool SPEC_interference = targ && parent && nojumpinSPEC
1342 unsigned char gender = 0;
1343 vector< Animation* > *anim = NULL;
1344 if (SPEC_interference)
1349 bool isDone =
false;
1350 if ( targ->
getRelation( parent ) >= min_docking_relationship
1352 bool hasDock = severity == 0 ? parent->
Dock( targ ) :
SuperDock( parent, targ );
1361 }
else if (
UnDockNow( parent, targ ) ) {
1387 true ), clearencetime ) );
1398 bool isDone =
false;
1400 for (
int severity = 0; severity < maxseverity; ++severity) {
1402 if ( ( isDone =
TryDock( parent, targ, playa, severity ) ) !=
false ) {
1411 for (
int severity = 0; severity < maxseverity && !isDone; ++severity)
1413 (targ = *u) != NULL && !isDone;
1417 if ( (targ != parent)
1421 if (
TryDock( parent, targ, playa, severity ) ) {
1443 "[Computer] Cannot dock with insubstantidisabal object, target another object and retry." );
1446 }
else if (!wasdock) {
1472 this->refresh_target =
true;
1481 static Animation Statuc( comm_static.c_str() );
1489 unsigned int whichsound = 0;
1490 bool foundValidMessage =
false;
1494 bool reallydospeech =
false;
1495 if (un && un->
GetHull() > 0) {
1496 reallydospeech =
true;
1497 for (list< CommunicationMessage >::iterator
i = resp.begin();
i != resp.end();
i++)
1498 if ( (*i).sender.GetUnit() == un )
1499 if ( (
i = resp.erase(
i ) ) == resp.end() )
1501 resp.push_back( c );
1502 if (!foundValidMessage)
1521 for (list< CommunicationMessage >::iterator
i = messagequeue.begin();
i != messagequeue.end();
i++)
1522 if ( (*i).sender.GetUnit() == targ ) {
1538 bool attack = ownrel < 0;
1542 for (
unsigned int i = 0; (!attack) && i < parent->numCargo(); ++
i) {
1544 for (
unsigned int j = 0;
j < contra->
numCargo(); ++
j) {
1570 static std::string prison_system =
vs_config->
getVariable(
"galaxy",
"PrisonSystem",
"Sol/Nu_Pheonix" );
1571 std::string psys = prison_system+
"_"+fac;
1579 +
", you are under arrest! You will be taken to the prison system and will be tried for your crimes." );
1597 arrested_list_do_not_dereference.insert( parent );
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." );
1620 static bool force_change_only_unit =
1622 if (parent->
Target() == curtarg) {
1623 if (force_change_only_unit) {
1627 if (parent->
Target() == curtarg)
1638 static bool allow_special_with_weapons =
1640 if (!allow_special_with_weapons) {
1660 refresh_target =
true;
1668 refresh_target =
true;
1671 if (
f().shieldpowerstate != 1) {
1677 static bool allow_special_with_weapons =
1679 if (!allow_special_with_weapons) {
1680 bool special =
false;
1681 bool normal =
false;
1684 for (i = 0; i < nm; ++i)
1692 for (i = 0; i < nm; ++i)
1693 if (special && normal) {
1702 if (
f().missilekey ==
PRESS ||
j().jmissilekey ==
PRESS) {
1705 if (
f().missilekey ==
PRESS)
1707 if (
j().jmissilekey ==
PRESS)
1714 if (
f().cloakkey ==
PRESS) {
1717 cloaktoggle = !cloaktoggle;
1719 if (
f().lockkey ==
PRESS) {
1733 if (
f().blinkleftkey ==
PRESS) {
1734 f().blinkleftkey =
DOWN;
1740 if (
f().blinkrightkey ==
PRESS) {
1741 f().blinkrightkey =
DOWN;
1747 if (
f().sirenkey ==
PRESS) {
1748 f().sirenkey =
DOWN;
1754 if (
f().headlightkey ==
PRESS) {
1755 f().headlightkey =
DOWN;
1762 if (
f().targetkey ==
PRESS ||
j().jtargetkey ==
PRESS) {
1766 refresh_target =
true;
1768 if (
f().rtargetkey ==
PRESS) {
1771 refresh_target =
true;
1773 if (
f().missiontargetkey ==
PRESS) {
1776 refresh_target =
true;
1778 if (
f().rmissiontargetkey ==
PRESS) {
1781 refresh_target =
true;
1783 if (
f().targetskey ==
PRESS) {
1786 refresh_target =
true;
1789 if (
f().targetukey ==
PRESS) {
1791 static bool smart_targetting =
1794 bool sysobj =
false;
1804 refresh_target =
true;
1809 refresh_target =
true;
1811 if (
f().neartargetkey ==
PRESS) {
1814 refresh_target =
true;
1816 if (
f().missiletargetkey ==
PRESS) {
1819 refresh_target =
true;
1821 if (
f().incomingmissiletargetkey ==
PRESS) {
1824 refresh_target =
true;
1826 if (
f().rmissiletargetkey ==
PRESS) {
1829 refresh_target =
true;
1831 if (
f().rincomingmissiletargetkey ==
PRESS) {
1834 refresh_target =
true;
1836 if (
f().threattargetkey ==
PRESS) {
1839 refresh_target =
true;
1841 if (
f().subtargetkey ==
PRESS) {
1844 refresh_target =
true;
1846 if (
f().rpicktargetkey ==
PRESS) {
1849 refresh_target =
true;
1851 if (
f().rneartargetkey ==
PRESS) {
1854 refresh_target =
true;
1856 if (
f().rthreattargetkey ==
PRESS) {
1859 refresh_target =
true;
1861 if (
f().rtargetskey ==
PRESS) {
1864 refresh_target =
true;
1867 if (
f().rtargetukey ==
PRESS) {
1869 static bool smart_targetting =
1872 bool sysobj =
false;
1877 if (tmp ==
parent->
Target() && sysobj && smart_targetting) {
1882 refresh_target =
true;
1890 static int taicounter = 0;
1895 if (
f().turretfaw ==
PRESS) {
1901 if (
f().turrettargetkey ==
PRESS) {
1904 refresh_target =
true;
1909 refresh_target =
true;
1914 refresh_target =
true;
1916 if (
f().threatturrettargetkey ==
PRESS) {
1919 refresh_target =
true;
1922 if (
f().nearesthostilekey ==
PRESS) {
1925 refresh_target =
true;
1927 if (
f().nearestdangeroushostilekey ==
PRESS) {
1930 refresh_target =
true;
1932 if (
f().nearestfriendlykey ==
PRESS) {
1935 refresh_target =
true;
1937 if (
f().nearestbasekey ==
PRESS) {
1940 refresh_target =
true;
1942 if (
f().nearestplanetkey ==
PRESS) {
1945 refresh_target =
true;
1947 if (
f().nearestjumpkey ==
PRESS) {
1950 refresh_target =
true;
1952 if (
f().togglepausekey ==
PRESS) {
1965 if (
f().weapk ==
PRESS) {
1969 if (
f().rweapk ==
PRESS) {
1976 if (weapsound.
sound < 0) {
1982 if (
f().toggleanimation ==
PRESS) {
1986 if (
f().toggleglow ==
PRESS) {
1988 static bool isvis =
true;
1992 if (
f().togglewarpdrive ==
PRESS) {
1997 if (
f().toggleautotracking ==
PRESS) {
2007 if (
f().rmisk ==
PRESS) {
2013 if (missound.
sound < 0) {
2021 if (
f().saveTargetKeys[i] ==
PRESS) {
2038 if (
f().commKeys[i] ==
PRESS) {
2044 if ( mymsg == NULL || mymsg->
curstate >= static_cast<int>(fsm->
nodes.size()) ) {
2046 unsigned int whichspeech =
DoSpeech( targ, targ, *
c.getCurrentState() );
2047 int sound =
c.getCurrentState()->GetSound(
c.sex, whichspeech );
2057 if ( i < n->edges.size() ) {
2059 unsigned int whichmessage =
DoSpeech( targ, targ, *
c.getCurrentState() );
2060 int sound =
c.getCurrentState()->GetSound(
c.sex, whichmessage );
2071 if (refresh_target) {
2092 if (
f().ejectcargo ==
PRESS ||
f().ejectnonmissioncargo ==
PRESS) {
2101 for ( ; offset < static_cast<int>(
parent->
numCargo()); ++offset) {
2103 if ( tmp->
GetCategory().find(
"upgrades" ) == string::npos && (missiontoo || tmp->
mission ==
false) ) {
2114 if (
f().eject ==
PRESS) {
2121 if (
f().ejectdock ==
PRESS) {