Follow, tankers and AWACS completed

This commit is contained in:
Pax1601
2023-04-19 16:30:14 +02:00
parent f24c57cc18
commit c3c84b2115
5 changed files with 68 additions and 21 deletions

View File

@@ -169,6 +169,7 @@ protected:
/********** Mission data **********/
double fuel = 0;
double initialFuel = 0; // Used internally to detect refueling completed
json::value ammo = json::value::null();
json::value targets = json::value::null();
bool hasTask = false;
@@ -193,12 +194,12 @@ protected:
bool isTanker = false;
bool isAWACS = false;
bool TACANOn = false;
int TACANChannel = 0;
int TACANChannel = 40;
wstring TACANXY = L"X";
wstring TACANCallsign = L"TKR";
bool radioOn = false;
int radioFrequency = 0;
int radioCallsign = 0;
int radioFrequency = 260000000; // MHz
int radioCallsign = 1;
int radioCallsignNumber = 1;
/********** Options data **********/

View File

@@ -83,6 +83,7 @@ void AirUnit::setState(int newState)
break;
}
case State::REFUEL: {
initialFuel = fuel;
clearActivePath();
resetActiveDestination();
addMeasure(L"currentState", json::value(L"Refuel"));
@@ -192,6 +193,9 @@ void AirUnit::AIloop()
if (isTanker) {
taskSS << "{ [1] = { id = 'Tanker' }, [2] = { id = 'Orbit', pattern = 'Race-Track' } }";
}
else if (isAWACS) {
taskSS << "{ [1] = { id = 'AWACS' }, [2] = { id = 'Orbit', pattern = 'Circle' } }";
}
else {
taskSS << "{ id = 'Orbit', pattern = 'Circle' }";
}
@@ -239,7 +243,7 @@ void AirUnit::AIloop()
break;
}
case State::LAND: {
wstring enrouteTask = L"{" "id = 'land' }";
wstring enrouteTask = L"{ id = 'Land' }";
currentTask = L"Landing";
if (activeDestination == NULL)
@@ -311,13 +315,18 @@ void AirUnit::AIloop()
currentTask = L"Refueling";
if (!hasTask) {
std::wostringstream taskSS;
taskSS << "{"
<< "id = 'Refuel'"
<< "}";
Command* command = dynamic_cast<Command*>(new SetTask(ID, taskSS.str()));
scheduler->appendCommand(command);
hasTask = true;
if (fuel <= initialFuel) {
std::wostringstream taskSS;
taskSS << "{"
<< "id = 'Refuel'"
<< "}";
Command* command = dynamic_cast<Command*>(new SetTask(ID, taskSS.str()));
scheduler->appendCommand(command);
hasTask = true;
}
else {
setState(State::IDLE);
}
}
}
default: