Fixed setting skill level

This commit is contained in:
Stefan Arsic 2024-02-03 22:29:26 +01:00
parent 497f718e4b
commit 2124e9cd42
5 changed files with 36 additions and 49 deletions

View File

@ -165,12 +165,11 @@ private:
class SpawnGroundUnits : public Command
{
public:
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, string skill, bool immediate, function<void(void)> callback = [](){}) :
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate, function<void(void)> callback = [](){}) :
Command(callback),
coalition(coalition),
spawnOptions(spawnOptions),
country(country),
skill(skill),
immediate(immediate)
{
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
@ -182,7 +181,6 @@ private:
const string coalition;
const vector<SpawnOptions> spawnOptions;
const string country;
const string skill;
const bool immediate;
};
@ -190,12 +188,11 @@ private:
class SpawnNavyUnits : public Command
{
public:
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, string skill, bool immediate, function<void(void)> callback = [](){}) :
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate, function<void(void)> callback = [](){}) :
Command(callback),
coalition(coalition),
spawnOptions(spawnOptions),
country(country),
skill(skill),
immediate(immediate)
{
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
@ -207,7 +204,6 @@ private:
const string coalition;
const vector<SpawnOptions> spawnOptions;
const string country;
const string skill;
const bool immediate;
};
@ -215,13 +211,12 @@ private:
class SpawnAircrafts : public Command
{
public:
SpawnAircrafts(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, string country, string skill, bool immediate, function<void(void)> callback = [](){}) :
SpawnAircrafts(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, string country, bool immediate, function<void(void)> callback = [](){}) :
Command(callback),
coalition(coalition),
spawnOptions(spawnOptions),
airbaseName(airbaseName),
country(country),
skill(skill),
immediate(immediate)
{
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
@ -234,7 +229,6 @@ private:
const vector<SpawnOptions> spawnOptions;
const string airbaseName;
const string country;
const string skill;
const bool immediate;
};
@ -242,13 +236,12 @@ private:
class SpawnHelicopters : public Command
{
public:
SpawnHelicopters(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, string country, string skill, bool immediate, function<void(void)> callback = [](){}) :
SpawnHelicopters(string coalition, vector<SpawnOptions> spawnOptions, string airbaseName, string country, bool immediate, function<void(void)> callback = [](){}) :
Command(callback),
coalition(coalition),
spawnOptions(spawnOptions),
airbaseName(airbaseName),
country(country),
skill(skill),
immediate(immediate)
{
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
@ -261,7 +254,6 @@ private:
const vector<SpawnOptions> spawnOptions;
const string airbaseName;
const string country;
const string skill;
const bool immediate;
};

View File

@ -46,8 +46,9 @@ string SpawnGroundUnits::getString()
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
<< "lat = " << spawnOptions[i].location.lat << ", "
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
}
std::ostringstream commandSS;
@ -56,7 +57,6 @@ string SpawnGroundUnits::getString()
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
<< "coalition = " << "\"" << coalition << "\"" << ", "
<< "country = \"" << country << "\", "
<< "skill = \"" << skill << "\", "
<< "units = " << "{" << unitsSS.str() << "}" << "}";
return commandSS.str();
}
@ -72,8 +72,8 @@ string SpawnNavyUnits::getString()
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
<< "lat = " << spawnOptions[i].location.lat << ", "
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
}
std::ostringstream commandSS;
@ -82,7 +82,6 @@ string SpawnNavyUnits::getString()
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
<< "coalition = " << "\"" << coalition << "\"" << ", "
<< "country = \"" << country << "\", "
<< "skill = \"" << skill << "\", "
<< "units = " << "{" << unitsSS.str() << "}" << "}";
return commandSS.str();
}
@ -99,8 +98,8 @@ string SpawnAircrafts::getString()
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "alt = " << spawnOptions[i].location.alt << ", "
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
}
std::ostringstream commandSS;
@ -110,7 +109,6 @@ string SpawnAircrafts::getString()
<< "coalition = " << "\"" << coalition << "\"" << ", "
<< "airbaseName = \"" << airbaseName << "\", "
<< "country = \"" << country << "\", "
<< "skill = \"" << skill << "\", "
<< "units = " << "{" << unitsSS.str() << "}" << "}";
return commandSS.str();
}
@ -128,8 +126,8 @@ string SpawnHelicopters::getString()
<< "lng = " << spawnOptions[i].location.lng << ", "
<< "alt = " << spawnOptions[i].location.alt << ", "
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << ", "
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
}
std::ostringstream commandSS;
@ -139,7 +137,6 @@ string SpawnHelicopters::getString()
<< "coalition = " << "\"" << coalition << "\"" << ", "
<< "airbaseName = \"" << airbaseName << "\", "
<< "country = \"" << country << "\", "
<< "skill = \"" << skill << "\", "
<< "units = " << "{" << unitsSS.str() << "}" << "}";
return commandSS.str();
}

View File

@ -191,7 +191,6 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
string coalition = to_string(value[L"coalition"]);
string airbaseName = to_string(value[L"airbaseName"]);
string country = to_string(value[L"country"]);
string skill = "";
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
@ -206,16 +205,16 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
Coords location; location.lat = lat; location.lng = lng; location.alt = alt;
string loadout = to_string(unit[L"loadout"]);
string liveryID = to_string(unit[L"liveryID"]);
skill = to_string(unit[L"skill"]);
string skill = to_string(unit[L"skill"]);
spawnOptions.push_back({unitType, location, loadout, liveryID});
log(username + " spawned a " + coalition + " " + unitType, true);
spawnOptions.push_back({unitType, location, loadout, skill, liveryID});
log(username + " spawned a " + coalition + " " + unitType , true);
}
if (key.compare("spawnAircrafts") == 0)
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, skill, immediate));
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, immediate));
else
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, spawnOptions, airbaseName, country, skill, immediate));
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, spawnOptions, airbaseName, country, immediate));
}
/************************/
else if (key.compare("spawnGroundUnits") == 0 || key.compare("spawnNavyUnits") == 0)
@ -223,7 +222,6 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
bool immediate = value[L"immediate"].as_bool();
string coalition = to_string(value[L"coalition"]);
string country = to_string(value[L"country"]);
string skill = "";
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
if (!checkSpawnPoints(spawnPoints, coalition)) return;
@ -235,16 +233,16 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
double lng = unit[L"location"][L"lng"].as_double();
Coords location; location.lat = lat; location.lng = lng;
string liveryID = to_string(unit[L"liveryID"]);
skill = to_string(unit[L"skill"]);
string skill = to_string(unit[L"skill"]);
spawnOptions.push_back({ unitType, location, "", liveryID });
spawnOptions.push_back({ unitType, location, "", skill, liveryID});
log(username + " spawned a " + coalition + " " + unitType, true);
}
if (key.compare("spawnGroundUnits") == 0)
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, country, skill, immediate));
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, country, immediate));
else
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, country, skill, immediate));
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, country, immediate));
}
/************************/
else if (key.compare("attackUnit") == 0)

View File

@ -273,7 +273,7 @@ export abstract class UnitSpawnMenu {
if (!this.#unitSkillDropdown.isHidden()) {
this.#unitSkillDropdown.setOptions(["Average", "Good", "High", "Excellent"])
this.#unitSkillDropdown.selectValue(3);
this.#unitSkillDropdown.selectValue(4);
}
/* Get the unit data from the db */

View File

@ -545,7 +545,7 @@ end
-- loadout: (string, optional) only for air units, must be one of the loadouts defined in unitPayloads.lua
-- payload: (table, optional) overrides loadout, specifies directly the loadout of the unit
-- liveryID: (string, optional)
function Olympus.spawnUnits(spawnTable, skill)
function Olympus.spawnUnits(spawnTable)
Olympus.debug("Olympus.spawnUnits " .. Olympus.serializeTable(spawnTable), 2)
local unitsTable = nil
@ -554,18 +554,18 @@ function Olympus.spawnUnits(spawnTable, skill)
-- Generate the units table and route as per DCS requirements
if spawnTable.category == 'Aircraft' then
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units)
route = Olympus.generateAirUnitsRoute(spawnTable)
category = 'plane'
elseif spawnTable.category == 'Helicopter' then
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units)
route = Olympus.generateAirUnitsRoute(spawnTable)
category = 'helicopter'
elseif spawnTable.category == 'GroundUnit' then
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units)
category = 'vehicle'
elseif spawnTable.category == 'NavyUnit' then
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units)
category = 'ship'
end
@ -600,7 +600,7 @@ function Olympus.spawnUnits(spawnTable, skill)
end
-- Generates unit table for air units
function Olympus.generateAirUnitsTable(units, skill)
function Olympus.generateAirUnitsTable(units)
local unitsTable = {}
for idx, unit in pairs(units) do
local loadout = unit.loadout -- loadout: a string, one of the names defined in unitPayloads.lua. Must be compatible with the unitType
@ -628,7 +628,7 @@ function Olympus.generateAirUnitsTable(units, skill)
["y"] = spawnLocation.z,
["alt"] = unit.alt,
["alt_type"] = "BARO",
["skill"] = skill,
["skill"] = unit.skill,
["payload"] = payload,
["heading"] = unit.heading,
["callsign"] = { [1] = 1, [2] = 1, [3] = 1, ["name"] = "Olympus" .. Olympus.unitCounter.. "-" .. #unitsTable + 1 },
@ -696,7 +696,7 @@ function Olympus.generateAirUnitsRoute(spawnTable)
end
-- Generates ground units table, either single or from template
function Olympus.generateGroundUnitsTable(units, skill)
function Olympus.generateGroundUnitsTable(units)
local unitsTable = {}
for idx, unit in pairs(units) do
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(unit.lat, unit.lng, 0))
@ -730,7 +730,7 @@ function Olympus.generateGroundUnitsTable(units, skill)
end
-- Generates navy units table, either single or from template
function Olympus.generateNavyUnitsTable(units, skill)
function Olympus.generateNavyUnitsTable(units)
local unitsTable = {}
for idx, unit in pairs(units) do
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(unit.lat, unit.lng, 0))
@ -1109,13 +1109,13 @@ function Olympus.setUnitsData(arg, time)
-- Generate the units table as per DCS requirements
if table["category"] == 'Aircraft' then
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units)
elseif table["category"] == 'Helicopter' then
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units)
elseif table["category"] == 'GroundUnit' then
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units)
elseif table["category"] == 'NavyUnit' then
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units, skill)
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units)
end
-- Save the units in the database, for cloning