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:
@@ -165,11 +165,12 @@ private:
|
|||||||
class SpawnGroundUnits : public Command
|
class SpawnGroundUnits : public Command
|
||||||
{
|
{
|
||||||
public:
|
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),
|
Command(callback),
|
||||||
coalition(coalition),
|
coalition(coalition),
|
||||||
spawnOptions(spawnOptions),
|
spawnOptions(spawnOptions),
|
||||||
country(country),
|
country(country),
|
||||||
|
skill(skill),
|
||||||
immediate(immediate)
|
immediate(immediate)
|
||||||
{
|
{
|
||||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||||
@@ -181,6 +182,7 @@ private:
|
|||||||
const string coalition;
|
const string coalition;
|
||||||
const vector<SpawnOptions> spawnOptions;
|
const vector<SpawnOptions> spawnOptions;
|
||||||
const string country;
|
const string country;
|
||||||
|
const string skill;
|
||||||
const bool immediate;
|
const bool immediate;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -188,11 +190,12 @@ private:
|
|||||||
class SpawnNavyUnits : public Command
|
class SpawnNavyUnits : public Command
|
||||||
{
|
{
|
||||||
public:
|
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),
|
Command(callback),
|
||||||
coalition(coalition),
|
coalition(coalition),
|
||||||
spawnOptions(spawnOptions),
|
spawnOptions(spawnOptions),
|
||||||
country(country),
|
country(country),
|
||||||
|
skill(skill),
|
||||||
immediate(immediate)
|
immediate(immediate)
|
||||||
{
|
{
|
||||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||||
@@ -204,6 +207,7 @@ private:
|
|||||||
const string coalition;
|
const string coalition;
|
||||||
const vector<SpawnOptions> spawnOptions;
|
const vector<SpawnOptions> spawnOptions;
|
||||||
const string country;
|
const string country;
|
||||||
|
const string skill;
|
||||||
const bool immediate;
|
const bool immediate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ string SpawnGroundUnits::getString()
|
|||||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||||
|
<< "skill = \"" << spawnOptions[i].skill << "\"" << ", "
|
||||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ string SpawnGroundUnits::getString()
|
|||||||
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
|
<< "category = " << "\"" << "GroundUnit" << "\"" << ", "
|
||||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||||
<< "country = \"" << country << "\", "
|
<< "country = \"" << country << "\", "
|
||||||
|
<< "skill = \"" << skill << "\", "
|
||||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||||
return commandSS.str();
|
return commandSS.str();
|
||||||
}
|
}
|
||||||
@@ -70,6 +72,7 @@ string SpawnNavyUnits::getString()
|
|||||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||||
|
<< "skill = \"" << spawnOptions[i].skill << "\"" << ", "
|
||||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +82,7 @@ string SpawnNavyUnits::getString()
|
|||||||
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
|
<< "category = " << "\"" << "NavyUnit" << "\"" << ", "
|
||||||
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
<< "coalition = " << "\"" << coalition << "\"" << ", "
|
||||||
<< "country = \"" << country << "\", "
|
<< "country = \"" << country << "\", "
|
||||||
|
<< "skill = \"" << skill << "\", "
|
||||||
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
<< "units = " << "{" << unitsSS.str() << "}" << "}";
|
||||||
return commandSS.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();
|
bool immediate = value[L"immediate"].as_bool();
|
||||||
string coalition = to_string(value[L"coalition"]);
|
string coalition = to_string(value[L"coalition"]);
|
||||||
string country = to_string(value[L"country"]);
|
string country = to_string(value[L"country"]);
|
||||||
|
string skill = "";
|
||||||
|
|
||||||
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
||||||
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
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();
|
double lng = unit[L"location"][L"lng"].as_double();
|
||||||
Coords location; location.lat = lat; location.lng = lng;
|
Coords location; location.lat = lat; location.lng = lng;
|
||||||
string liveryID = to_string(unit[L"liveryID"]);
|
string liveryID = to_string(unit[L"liveryID"]);
|
||||||
|
skill = to_string(unit[L"skill"]);
|
||||||
|
|
||||||
spawnOptions.push_back({ unitType, location, "", liveryID });
|
spawnOptions.push_back({ unitType, location, "", liveryID });
|
||||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.compare("spawnGroundUnits") == 0)
|
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
|
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)
|
else if (key.compare("attackUnit") == 0)
|
||||||
|
|||||||
@@ -754,7 +754,8 @@ export class GroundUnitSpawnMenu extends UnitSpawnMenu {
|
|||||||
var unitTable: UnitSpawnTable = {
|
var unitTable: UnitSpawnTable = {
|
||||||
unitType: spawnOptions.name,
|
unitType: spawnOptions.name,
|
||||||
location: spawnOptions.latlng,
|
location: spawnOptions.latlng,
|
||||||
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "",
|
||||||
|
skill: spawnOptions.skill ? spawnOptions.skill : "High"
|
||||||
};
|
};
|
||||||
|
|
||||||
var units = [];
|
var units = [];
|
||||||
@@ -804,7 +805,8 @@ export class NavyUnitSpawnMenu extends UnitSpawnMenu {
|
|||||||
var unitTable: UnitSpawnTable = {
|
var unitTable: UnitSpawnTable = {
|
||||||
unitType: spawnOptions.name,
|
unitType: spawnOptions.name,
|
||||||
location: spawnOptions.latlng,
|
location: spawnOptions.latlng,
|
||||||
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: ""
|
liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "",
|
||||||
|
skill: spawnOptions.skill ? spawnOptions.skill : "High"
|
||||||
};
|
};
|
||||||
|
|
||||||
var units = [];
|
var units = [];
|
||||||
|
|||||||
@@ -562,10 +562,10 @@ function Olympus.spawnUnits(spawnTable, skill)
|
|||||||
route = Olympus.generateAirUnitsRoute(spawnTable)
|
route = Olympus.generateAirUnitsRoute(spawnTable)
|
||||||
category = 'helicopter'
|
category = 'helicopter'
|
||||||
elseif spawnTable.category == 'GroundUnit' then
|
elseif spawnTable.category == 'GroundUnit' then
|
||||||
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units)
|
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units, skill)
|
||||||
category = 'vehicle'
|
category = 'vehicle'
|
||||||
elseif spawnTable.category == 'NavyUnit' then
|
elseif spawnTable.category == 'NavyUnit' then
|
||||||
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units)
|
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units, skill)
|
||||||
category = 'ship'
|
category = 'ship'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -696,7 +696,7 @@ function Olympus.generateAirUnitsRoute(spawnTable)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Generates ground units table, either single or from template
|
-- Generates ground units table, either single or from template
|
||||||
function Olympus.generateGroundUnitsTable(units)
|
function Olympus.generateGroundUnitsTable(units, skill)
|
||||||
local unitsTable = {}
|
local unitsTable = {}
|
||||||
for idx, unit in pairs(units) do
|
for idx, unit in pairs(units) do
|
||||||
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(unit.lat, unit.lng, 0))
|
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,
|
["x"] = spawnLocation.x + value.dx,
|
||||||
["y"] = spawnLocation.z + value.dy,
|
["y"] = spawnLocation.z + value.dy,
|
||||||
["heading"] = 0,
|
["heading"] = 0,
|
||||||
["skill"] = "High",
|
["skill"] = skill,
|
||||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1
|
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -719,7 +719,7 @@ function Olympus.generateGroundUnitsTable(units)
|
|||||||
["x"] = spawnLocation.x,
|
["x"] = spawnLocation.x,
|
||||||
["y"] = spawnLocation.z,
|
["y"] = spawnLocation.z,
|
||||||
["heading"] = unit.heading,
|
["heading"] = unit.heading,
|
||||||
["skill"] = "High",
|
["skill"] = skill,
|
||||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||||
["livery_id"] = unit.liveryID
|
["livery_id"] = unit.liveryID
|
||||||
}
|
}
|
||||||
@@ -730,7 +730,7 @@ function Olympus.generateGroundUnitsTable(units)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Generates navy units table, either single or from template
|
-- Generates navy units table, either single or from template
|
||||||
function Olympus.generateNavyUnitsTable(units)
|
function Olympus.generateNavyUnitsTable(units, skill)
|
||||||
local unitsTable = {}
|
local unitsTable = {}
|
||||||
for idx, unit in pairs(units) do
|
for idx, unit in pairs(units) do
|
||||||
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(unit.lat, unit.lng, 0))
|
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,
|
["x"] = spawnLocation.x + value.dx,
|
||||||
["y"] = spawnLocation.z + value.dy,
|
["y"] = spawnLocation.z + value.dy,
|
||||||
["heading"] = 0,
|
["heading"] = 0,
|
||||||
["skill"] = "High",
|
["skill"] = skill,
|
||||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||||
["transportable"] = { ["randomTransportable"] = false }
|
["transportable"] = { ["randomTransportable"] = false }
|
||||||
}
|
}
|
||||||
@@ -754,7 +754,7 @@ function Olympus.generateNavyUnitsTable(units)
|
|||||||
["x"] = spawnLocation.x,
|
["x"] = spawnLocation.x,
|
||||||
["y"] = spawnLocation.z,
|
["y"] = spawnLocation.z,
|
||||||
["heading"] = unit.heading,
|
["heading"] = unit.heading,
|
||||||
["skill"] = "High",
|
["skill"] = skill,
|
||||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||||
["transportable"] = { ["randomTransportable"] = false },
|
["transportable"] = { ["randomTransportable"] = false },
|
||||||
["livery_id"] = unit.liveryID
|
["livery_id"] = unit.liveryID
|
||||||
@@ -1113,9 +1113,9 @@ function Olympus.setUnitsData(arg, time)
|
|||||||
elseif table["category"] == 'Helicopter' then
|
elseif table["category"] == 'Helicopter' then
|
||||||
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
|
unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill)
|
||||||
elseif table["category"] == 'GroundUnit' then
|
elseif table["category"] == 'GroundUnit' then
|
||||||
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units)
|
unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units, skill)
|
||||||
elseif table["category"] == 'NavyUnit' then
|
elseif table["category"] == 'NavyUnit' then
|
||||||
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units)
|
unitsTable = Olympus.generateNavyUnitsTable(spawnTable.units, skill)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Save the units in the database, for cloning
|
-- Save the units in the database, for cloning
|
||||||
|
|||||||
Reference in New Issue
Block a user