mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added livery ID
This commit is contained in:
parent
187fcd3d85
commit
27d77f97db
@ -1230,6 +1230,7 @@
|
||||
"name": "Empty Loadout"
|
||||
}
|
||||
],
|
||||
"liveryID": ["ir iriaf 43rd tfs"],
|
||||
"filename": "f-5.png"
|
||||
},
|
||||
"F-86F Sabre": {
|
||||
|
||||
1
client/src/@types/unitdatabase.d.ts
vendored
1
client/src/@types/unitdatabase.d.ts
vendored
@ -22,4 +22,5 @@ interface UnitBlueprint {
|
||||
range?: string;
|
||||
loadouts?: LoadoutBlueprint[];
|
||||
filename?: string;
|
||||
liveryID?: string;
|
||||
}
|
||||
|
||||
@ -92,7 +92,8 @@ export class MapContextMenu extends ContextMenu {
|
||||
document.addEventListener("contextMenuDeployAircrafts", () => {
|
||||
this.#spawnOptions.coalition = getActiveCoalition();
|
||||
if (this.#spawnOptions) {
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, altitude: this.#spawnOptions.altitude, loadout: this.#spawnOptions.loadout};
|
||||
const liveryID = aircraftDatabase.getByName(this.#spawnOptions.name)?.liveryID;
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, altitude: this.#spawnOptions.altitude, loadout: this.#spawnOptions.loadout, liveryID: liveryID? liveryID: ""};
|
||||
var units = [];
|
||||
for (let i = 1; i < parseInt(this.#aircraftCountDropdown.getValue()) + 1; i++) {
|
||||
units.push(unitTable);
|
||||
@ -107,7 +108,8 @@ export class MapContextMenu extends ContextMenu {
|
||||
document.addEventListener("contextMenuDeployHelicopters", () => {
|
||||
this.#spawnOptions.coalition = getActiveCoalition();
|
||||
if (this.#spawnOptions) {
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, altitude: this.#spawnOptions.altitude, loadout: this.#spawnOptions.loadout};
|
||||
const liveryID = aircraftDatabase.getByName(this.#spawnOptions.name)?.liveryID;
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, altitude: this.#spawnOptions.altitude, loadout: this.#spawnOptions.loadout, liveryID: liveryID? liveryID: ""};
|
||||
var units = [];
|
||||
for (let i = 1; i < parseInt(this.#helicopterCountDropdown.getValue()) + 1; i++) {
|
||||
units.push(unitTable);
|
||||
@ -122,7 +124,8 @@ export class MapContextMenu extends ContextMenu {
|
||||
document.addEventListener("contextMenuDeployGroundUnits", () => {
|
||||
this.#spawnOptions.coalition = getActiveCoalition();
|
||||
if (this.#spawnOptions) {
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng};
|
||||
const liveryID = aircraftDatabase.getByName(this.#spawnOptions.name)?.liveryID;
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, liveryID: liveryID? liveryID: ""};
|
||||
var units = [];
|
||||
for (let i = 1; i < parseInt(this.#groundUnitCountDropdown.getValue()) + 1; i++) {
|
||||
units.push(JSON.parse(JSON.stringify(unitTable)));
|
||||
@ -138,7 +141,8 @@ export class MapContextMenu extends ContextMenu {
|
||||
document.addEventListener("contextMenuDeployNavyUnits", () => {
|
||||
this.#spawnOptions.coalition = getActiveCoalition();
|
||||
if (this.#spawnOptions) {
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng};
|
||||
const liveryID = aircraftDatabase.getByName(this.#spawnOptions.name)?.liveryID;
|
||||
var unitTable = {unitType: this.#spawnOptions.name, location: this.#spawnOptions.latlng, liveryID: liveryID? liveryID: ""};
|
||||
var units = [];
|
||||
for (let i = 1; i < parseInt(this.#navyUnitCountDropdown.getValue()) + 1; i++) {
|
||||
units.push(JSON.parse(JSON.stringify(unitTable)));
|
||||
|
||||
@ -77,7 +77,7 @@ export class MissionHandler {
|
||||
this.#dateAndTime = data.mission.dateAndTime;
|
||||
|
||||
/* Set the coalition countries */
|
||||
this.#coalitions = data.mission.coalitions;
|
||||
//this.#coalitions = data.mission.coalitions;
|
||||
|
||||
/* Set the command mode options */
|
||||
this.#setcommandModeOptions(data.mission.commandModeOptions);
|
||||
|
||||
@ -311,6 +311,11 @@ export class Unit extends CustomMarker {
|
||||
}
|
||||
}
|
||||
|
||||
getLiveryID(): string {
|
||||
const liveryID = this.getDatabase()?.getByName(this.getName())?.liveryID;
|
||||
return liveryID? liveryID: "";
|
||||
}
|
||||
|
||||
setAlive(newAlive: boolean) {
|
||||
if (newAlive != this.#alive)
|
||||
document.dispatchEvent(new CustomEvent("unitDeath", { detail: this }));
|
||||
|
||||
@ -555,7 +555,7 @@ export class UnitsManager {
|
||||
var unit = selectedUnits[idx];
|
||||
coalition = unit.getCoalition();
|
||||
deleteUnit(unit.ID, false, true);
|
||||
units.push({unitType: unit.getName(), location: unit.getPosition()});
|
||||
units.push({unitType: unit.getName(), location: unit.getPosition(), liveryID: unit.getLiveryID()});
|
||||
}
|
||||
const category = this.getSelectedUnitsTypes()[0];
|
||||
this.spawnUnits(category, units, coalition, true);
|
||||
@ -593,7 +593,8 @@ export class UnitsManager {
|
||||
var units = groups[groupName].map((unit: any) => {
|
||||
var position = new LatLng(getMap().getMouseCoordinates().lat + unit.position.lat - avgLat, getMap().getMouseCoordinates().lng + unit.position.lng - avgLng);
|
||||
getMap().addTemporaryMarker(position, unit.name, unit.coalition);
|
||||
return {unitType: unit.name, location: position};
|
||||
const liveryID = unit.getDatabase()?.getByName(unit.getName())?.liveryID;
|
||||
return {unitType: unit.name, location: position, liveryID: liveryID? liveryID: ""};
|
||||
});
|
||||
this.spawnUnits(groups[groupName][0].category, units, groups[groupName][0].coalition, true);
|
||||
}
|
||||
@ -629,7 +630,8 @@ export class UnitsManager {
|
||||
if (Math.random() < IADSDensities[type]) {
|
||||
const unitBlueprint = randomUnitBlueprint(groundUnitDatabase, {type: type, eras: activeEras, ranges: activeRanges});
|
||||
if (unitBlueprint) {
|
||||
this.spawnUnits("GroundUnit", [{unitType: unitBlueprint.name, location: latlng}], coalitionArea.getCoalition(), true);
|
||||
const liveryID = unitBlueprint.liveryID;
|
||||
this.spawnUnits("GroundUnit", [{unitType: unitBlueprint.name, location: latlng, liveryID: liveryID? liveryID: ""}], coalitionArea.getCoalition(), true);
|
||||
getMap().addTemporaryMarker(latlng, unitBlueprint.name, coalitionArea.getCoalition());
|
||||
}
|
||||
}
|
||||
@ -673,7 +675,10 @@ export class UnitsManager {
|
||||
for (let groupName in groups) {
|
||||
if (groupName !== "" && groups[groupName].length > 0 && (groups[groupName].every((unit: any) => {return unit.category == "GroundUnit";}) || groups[groupName].every((unit: any) => {return unit.category == "NavyUnit";}))) {
|
||||
var aliveUnits = groups[groupName].filter((unit: any) => {return unit.alive});
|
||||
var units = aliveUnits.map((unit: any) => {return {unitType: unit.name, location: unit.position}});
|
||||
var units = aliveUnits.map((unit: any) => {
|
||||
const liveryID = unit.getDatabase()?.getByName(unit.getName())?.liveryID;
|
||||
return { unitType: unit.name, location: unit.position, liveryID: liveryID? liveryID: "" }
|
||||
});
|
||||
getUnitsManager().spawnUnits(groups[groupName][0].category, units, groups[groupName][0].coalition, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,7 +447,8 @@ function Olympus.generateAirUnitsTable(units)
|
||||
["payload"] = { ["pylons"] = payload, ["fuel"] = 999999, ["flare"] = 60, ["ammo_type"] = 1, ["chaff"] = 60, ["gun"] = 100, },
|
||||
["heading"] = 0,
|
||||
["callsign"] = { [1] = 1, [2] = 1, [3] = 1, ["name"] = "Olympus" .. Olympus.unitCounter.. "-" .. #unitTable + 1 },
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1,
|
||||
["livery_id"] = unit.liveryID
|
||||
}
|
||||
end
|
||||
return unitTable
|
||||
@ -534,7 +535,8 @@ function Olympus.generateGroundUnitsTable(units)
|
||||
["y"] = spawnLocation.z,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High",
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1,
|
||||
["livery_id"] = unit.liveryID
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -569,7 +571,8 @@ function Olympus.generateNavyUnitsTable(units)
|
||||
["heading"] = 0,
|
||||
["skill"] = "High",
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitTable + 1,
|
||||
["transportable"] = { ["randomTransportable"] = false }
|
||||
["transportable"] = { ["randomTransportable"] = false },
|
||||
["livery_id"] = unit.liveryID
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -154,10 +154,11 @@ private:
|
||||
class SpawnGroundUnits : public Command
|
||||
{
|
||||
public:
|
||||
SpawnGroundUnits(string coalition, vector<string> unitTypes, vector<Coords> locations, bool immediate) :
|
||||
SpawnGroundUnits(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> liveryIDs, bool immediate) :
|
||||
coalition(coalition),
|
||||
unitTypes(unitTypes),
|
||||
locations(locations),
|
||||
liveryIDs(liveryIDs),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate? CommandPriority::IMMEDIATE: CommandPriority::LOW;
|
||||
@ -169,6 +170,7 @@ private:
|
||||
const string coalition;
|
||||
const vector<string> unitTypes;
|
||||
const vector<Coords> locations;
|
||||
const vector<string> liveryIDs;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
@ -176,10 +178,11 @@ private:
|
||||
class SpawnNavyUnits : public Command
|
||||
{
|
||||
public:
|
||||
SpawnNavyUnits(string coalition, vector<string> unitTypes, vector<Coords> locations, bool immediate) :
|
||||
SpawnNavyUnits(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> liveryIDs, bool immediate) :
|
||||
coalition(coalition),
|
||||
unitTypes(unitTypes),
|
||||
locations(locations),
|
||||
liveryIDs(liveryIDs),
|
||||
immediate(immediate)
|
||||
{
|
||||
priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW;
|
||||
@ -191,6 +194,7 @@ private:
|
||||
const string coalition;
|
||||
const vector<string> unitTypes;
|
||||
const vector<Coords> locations;
|
||||
const vector<string> liveryIDs;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
@ -198,11 +202,12 @@ private:
|
||||
class SpawnAircrafts : public Command
|
||||
{
|
||||
public:
|
||||
SpawnAircrafts(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> loadouts, string airbaseName, bool immediate) :
|
||||
SpawnAircrafts(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> loadouts, vector<string> liveryIDs, string airbaseName, bool immediate) :
|
||||
coalition(coalition),
|
||||
unitTypes(unitTypes),
|
||||
locations(locations),
|
||||
loadouts(loadouts),
|
||||
liveryIDs(liveryIDs),
|
||||
airbaseName(airbaseName),
|
||||
immediate(immediate)
|
||||
{
|
||||
@ -216,6 +221,7 @@ private:
|
||||
const vector<string> unitTypes;
|
||||
const vector<Coords> locations;
|
||||
const vector<string> loadouts;
|
||||
const vector<string> liveryIDs;
|
||||
const string airbaseName;
|
||||
const bool immediate;
|
||||
};
|
||||
@ -225,11 +231,12 @@ private:
|
||||
class SpawnHelicopters : public Command
|
||||
{
|
||||
public:
|
||||
SpawnHelicopters(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> loadouts, string airbaseName, bool immediate) :
|
||||
SpawnHelicopters(string coalition, vector<string> unitTypes, vector<Coords> locations, vector<string> loadouts, vector<string> liveryIDs, string airbaseName, bool immediate) :
|
||||
coalition(coalition),
|
||||
unitTypes(unitTypes),
|
||||
locations(locations),
|
||||
loadouts(loadouts),
|
||||
liveryIDs(liveryIDs),
|
||||
airbaseName(airbaseName),
|
||||
immediate(immediate)
|
||||
{
|
||||
@ -243,6 +250,7 @@ private:
|
||||
const vector<string> unitTypes;
|
||||
const vector<Coords> locations;
|
||||
const vector<string> loadouts;
|
||||
const vector<string> liveryIDs;
|
||||
const string airbaseName;
|
||||
const bool immediate;
|
||||
};
|
||||
|
||||
@ -48,7 +48,8 @@ string SpawnGroundUnits::getString()
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "unitType = " << "\"" << unitTypes[i] << "\"" << ", "
|
||||
<< "lat = " << locations[i].lat << ", "
|
||||
<< "lng = " << locations[i].lng << "},";
|
||||
<< "lng = " << locations[i].lng << ", "
|
||||
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
@ -72,7 +73,8 @@ string SpawnNavyUnits::getString()
|
||||
unitsSS << "[" << i + 1 << "] = {"
|
||||
<< "unitType = " << "\"" << unitTypes[i] << "\"" << ", "
|
||||
<< "lat = " << locations[i].lat << ", "
|
||||
<< "lng = " << locations[i].lng << "},";
|
||||
<< "lng = " << locations[i].lng << ", "
|
||||
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
@ -97,7 +99,8 @@ string SpawnAircrafts::getString()
|
||||
<< "lat = " << locations[i].lat << ", "
|
||||
<< "lng = " << locations[i].lng << ", "
|
||||
<< "alt = " << locations[i].alt << ", "
|
||||
<< "loadout = \"" << loadouts[i] << "\"" << "},";
|
||||
<< "loadout = \"" << loadouts[i] << "\"" << ", "
|
||||
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
@ -124,7 +127,8 @@ string SpawnHelicopters::getString()
|
||||
<< "lat = " << locations[i].lat << ", "
|
||||
<< "lng = " << locations[i].lng << ", "
|
||||
<< "alt = " << locations[i].alt << ", "
|
||||
<< "loadout = \"" << loadouts[i] << "\"" << "},";
|
||||
<< "loadout = \"" << loadouts[i] << "\"" << ", "
|
||||
<< "liveryID = " << "\"" << liveryIDs[i] << "\"" << " }, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
|
||||
@ -186,6 +186,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
vector<string> unitTypes;
|
||||
vector<Coords> locations;
|
||||
vector<string> loadouts;
|
||||
vector<string> liveryIDs;
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
string unitType = to_string(unit[L"unitType"]);
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
@ -193,14 +194,16 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
double alt = unit[L"altitude"].as_double();
|
||||
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"]);
|
||||
|
||||
unitTypes.push_back(unitType);
|
||||
locations.push_back(location);
|
||||
loadouts.push_back(loadout);
|
||||
liveryIDs.push_back(liveryID);
|
||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||
}
|
||||
|
||||
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, unitTypes, locations, loadouts, airbaseName, immediate));
|
||||
command = dynamic_cast<Command*>(new SpawnAircrafts(coalition, unitTypes, locations, liveryIDs, loadouts, airbaseName, immediate));
|
||||
}
|
||||
else if (key.compare("spawnHelicopters") == 0)
|
||||
{
|
||||
@ -214,6 +217,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
vector<string> unitTypes;
|
||||
vector<Coords> locations;
|
||||
vector<string> loadouts;
|
||||
vector<string> liveryIDs;
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
string unitType = to_string(unit[L"unitType"]);
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
@ -221,14 +225,16 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
double alt = unit[L"altitude"].as_double();
|
||||
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"]);
|
||||
|
||||
unitTypes.push_back(unitType);
|
||||
locations.push_back(location);
|
||||
loadouts.push_back(loadout);
|
||||
liveryIDs.push_back(liveryID);
|
||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||
}
|
||||
|
||||
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, unitTypes, locations, loadouts, airbaseName, immediate));
|
||||
command = dynamic_cast<Command*>(new SpawnHelicopters(coalition, unitTypes, locations, loadouts, liveryIDs, airbaseName, immediate));
|
||||
}
|
||||
else if (key.compare("spawnGroundUnits") == 0)
|
||||
{
|
||||
@ -240,18 +246,21 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
|
||||
vector<string> unitTypes;
|
||||
vector<Coords> locations;
|
||||
vector<string> liveryIDs;
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
string unitType = to_string(unit[L"unitType"]);
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
double lng = unit[L"location"][L"lng"].as_double();
|
||||
Coords location; location.lat = lat; location.lng = lng;
|
||||
string liveryID = to_string(unit[L"liveryID"]);
|
||||
|
||||
unitTypes.push_back(unitType);
|
||||
locations.push_back(location);
|
||||
liveryIDs.push_back(liveryID);
|
||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||
}
|
||||
|
||||
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, unitTypes, locations, immediate));
|
||||
command = dynamic_cast<Command*>(new SpawnGroundUnits(coalition, unitTypes, locations, liveryIDs, immediate));
|
||||
}
|
||||
else if (key.compare("spawnNavyUnits") == 0)
|
||||
{
|
||||
@ -263,18 +272,21 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
|
||||
vector<string> unitTypes;
|
||||
vector<Coords> locations;
|
||||
vector<string> liveryIDs;
|
||||
for (auto unit : value[L"units"].as_array()) {
|
||||
string unitType = to_string(unit[L"unitType"]);
|
||||
double lat = unit[L"location"][L"lat"].as_double();
|
||||
double lng = unit[L"location"][L"lng"].as_double();
|
||||
Coords location; location.lat = lat; location.lng = lng;
|
||||
string liveryID = to_string(unit[L"liveryID"]);
|
||||
|
||||
unitTypes.push_back(unitType);
|
||||
locations.push_back(location);
|
||||
liveryIDs.push_back(liveryID);
|
||||
log(username + " spawned a " + coalition + " " + unitType, true);
|
||||
}
|
||||
|
||||
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, unitTypes, locations, immediate));
|
||||
command = dynamic_cast<Command*>(new SpawnNavyUnits(coalition, unitTypes, locations, liveryIDs, immediate));
|
||||
}
|
||||
else if (key.compare("attackUnit") == 0)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user