mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added option for ground units to change skill
This commit is contained in:
parent
9942ff476b
commit
497f718e4b
@ -165,11 +165,12 @@ private:
|
||||
class SpawnGroundUnits : public Command
|
||||
{
|
||||
public:
|
||||
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate, function<void(void)> callback = [](){}) :
|
||||
SpawnGroundUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, string skill, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
coalition(coalition),
|
||||
spawnOptions(spawnOptions),
|
||||
country(country),
|
||||
skill(skill),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||
@ -181,6 +182,7 @@ private:
|
||||
const string coalition;
|
||||
const vector<SpawnOptions> spawnOptions;
|
||||
const string country;
|
||||
const string skill;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
@ -188,11 +190,12 @@ private:
|
||||
class SpawnNavyUnits : public Command
|
||||
{
|
||||
public:
|
||||
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, bool immediate, function<void(void)> callback = [](){}) :
|
||||
SpawnNavyUnits(string coalition, vector<SpawnOptions> spawnOptions, string country, string skill, bool immediate, function<void(void)> callback = [](){}) :
|
||||
Command(callback),
|
||||
coalition(coalition),
|
||||
spawnOptions(spawnOptions),
|
||||
country(country),
|
||||
skill(skill),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
@ -204,6 +207,7 @@ private:
|
||||
const string coalition;
|
||||
const vector<SpawnOptions> spawnOptions;
|
||||
const string country;
|
||||
const string skill;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ 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 << "\"" << " }, ";
|
||||
}
|
||||
|
||||
@ -55,6 +56,7 @@ string SpawnGroundUnits::getString()
|
||||
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
|
||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||
<< "country = \"" << country << "\", "
|
||||
<< "skill = \"" << skill << "\", "
|
||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||
return commandSS.str();
|
||||
}
|
||||
@ -70,6 +72,7 @@ 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 << "\"" << " }, ";
|
||||
}
|
||||
|
||||
@ -79,6 +82,7 @@ string SpawnNavyUnits::getString()
|
||||
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
|
||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||
<< "country = \"" << country << "\", "
|
||||
<< "skill = \"" << skill << "\", "
|
||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||
return commandSS.str();
|
||||
}
|
||||
|
||||
@ -223,6 +223,7 @@ 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;
|
||||
@ -234,15 +235,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"]);
|
||||
|
||||
spawnOptions.push_back({ unitType, location, "", liveryID });
|
||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||
}
|
||||
|
||||
if (key.compare("spawnGroundUnits") == 0)
|
||||
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, country, immediate));
|
||||
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, spawnOptions, country, skill, immediate));
|
||||
else
|
||||
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, country, immediate));
|
||||
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, spawnOptions, country, skill, immediate));
|
||||
}
|
||||
/************************/
|
||||
else if (key.compare("attackUnit") == 0)
|
||||
|
||||
@ -754,7 +754,8 @@ export class GroundUnitSpawnMenu extends UnitSpawnMenu {
|
||||
var unitTable: UnitSpawnTable = {
|
||||
unitType: spawnOptions.name,
|
||||
location: spawnOptions.latlng,
|
||||
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
||||
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "",
|
||||
skill: spawnOptions.skill ? spawnOptions.skill : "High"
|
||||
};
|
||||
|
||||
var units = [];
|
||||
@ -804,7 +805,8 @@ export class NavyUnitSpawnMenu extends UnitSpawnMenu {
|
||||
var unitTable: UnitSpawnTable = {
|
||||
unitType: spawnOptions.name,
|
||||
location: spawnOptions.latlng,
|
||||
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
||||
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "",
|
||||
skill: spawnOptions.skill ? spawnOptions.skill : "High"
|
||||
};
|
||||
|
||||
var units = [];
|
||||
|
||||
@ -562,10 +562,10 @@ function Olympus.spawnUnits(spawnTable, skill)
|
||||
route = Olympus.generateAirUnitsRoute(spawnTable)
|
||||
category = 'helicopter'
|
||||
elseif spawnTable.category == 'GroundUnit' then
|
||||
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units)
|
||||
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units, skill)
|
||||
category = 'vehicle'
|
||||
elseif spawnTable.category == 'NavyUnit' then
|
||||
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units)
|
||||
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units, skill)
|
||||
category = 'ship'
|
||||
end
|
||||
|
||||
@ -696,7 +696,7 @@ function Olympus.generateAirUnitsRoute(spawnTable)
|
||||
end
|
||||
|
||||
-- Generates ground units table, either single or from template
|
||||
function Olympus.generateGroundUnitsTable(units)
|
||||
function Olympus.generateGroundUnitsTable(units, skill)
|
||||
local unitsTable = {}
|
||||
for idx, unit in pairs(units) do
|
||||
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(unit.lat, unit.lng, 0))
|
||||
@ -708,7 +708,7 @@ function Olympus.generateGroundUnitsTable(units)
|
||||
["x"] = spawnLocation.x + value.dx,
|
||||
["y"] = spawnLocation.z + value.dy,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High",
|
||||
["skill"] = skill,
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1
|
||||
}
|
||||
end
|
||||
@ -719,7 +719,7 @@ function Olympus.generateGroundUnitsTable(units)
|
||||
["x"] = spawnLocation.x,
|
||||
["y"] = spawnLocation.z,
|
||||
["heading"] = unit.heading,
|
||||
["skill"] = "High",
|
||||
["skill"] = skill,
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||
["livery_id"] = unit.liveryID
|
||||
}
|
||||
@ -730,7 +730,7 @@ function Olympus.generateGroundUnitsTable(units)
|
||||
end
|
||||
|
||||
-- Generates navy units table, either single or from template
|
||||
function Olympus.generateNavyUnitsTable(units)
|
||||
function Olympus.generateNavyUnitsTable(units, skill)
|
||||
local unitsTable = {}
|
||||
for idx, unit in pairs(units) do
|
||||
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(unit.lat, unit.lng, 0))
|
||||
@ -742,7 +742,7 @@ function Olympus.generateNavyUnitsTable(units)
|
||||
["x"] = spawnLocation.x + value.dx,
|
||||
["y"] = spawnLocation.z + value.dy,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High",
|
||||
["skill"] = skill,
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||
["transportable"] = { ["randomTransportable"] = false }
|
||||
}
|
||||
@ -754,7 +754,7 @@ function Olympus.generateNavyUnitsTable(units)
|
||||
["x"] = spawnLocation.x,
|
||||
["y"] = spawnLocation.z,
|
||||
["heading"] = unit.heading,
|
||||
["skill"] = "High",
|
||||
["skill"] = skill,
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||
["transportable"] = { ["randomTransportable"] = false },
|
||||
["livery_id"] = unit.liveryID
|
||||
@ -1113,9 +1113,9 @@ function Olympus.setUnitsData(arg, time)
|
||||
elseif table["category"] == 'Helicopter' then
|
||||
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
|
||||
elseif table["category"] == 'GroundUnit' then
|
||||
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units)
|
||||
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units, skill)
|
||||
elseif table["category"] == 'NavyUnit' then
|
||||
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units)
|
||||
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units, skill)
|
||||
end
|
||||
|
||||
-- Save the units in the database, for cloning
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user