From 89fb0a9da1bc35d40befe05d8bd55475818834d8 Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:10:35 +0100 Subject: [PATCH 01/11] Hopefully added something that can make the flight skill change --- client/@types/olympus/index.d.ts | 2 ++ client/src/controls/unitspawnmenu.ts | 44 +++++++++++++++++++++++----- client/src/interfaces.ts | 2 ++ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/client/@types/olympus/index.d.ts b/client/@types/olympus/index.d.ts index c37bdcae..61fac735 100644 --- a/client/@types/olympus/index.d.ts +++ b/client/@types/olympus/index.d.ts @@ -649,6 +649,7 @@ declare module "interfaces" { coalition: string; count: number; country: string; + skill: string; loadout: LoadoutBlueprint | undefined; airbase: Airbase | undefined; liveryID: string | undefined; @@ -895,6 +896,7 @@ declare module "controls/unitspawnmenu" { getLabelDropdown(): Dropdown; getCountDropdown(): Dropdown; getLoadoutDropdown(): Dropdown; + getSkillDropdown(): Dropdown; getCountryDropdown(): Dropdown; getLiveryDropdown(): Dropdown; getLoadoutPreview(): HTMLDivElement; diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index eebcaa31..14743167 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -27,6 +27,7 @@ export abstract class UnitSpawnMenu { coalition: "blue", count: 1, country: "", + skill: "Excellent", loadout: undefined, airbase: undefined, liveryID: undefined, @@ -45,6 +46,7 @@ export abstract class UnitSpawnMenu { #unitLabelDropdown: Dropdown; #unitCountDropdown: Dropdown; #unitLoadoutDropdown: Dropdown; + #unitSkillDropdown: Dropdown; #unitCountryDropdown: Dropdown; #unitLiveryDropdown: Dropdown; #unitSpawnAltitudeSlider: Slider; @@ -77,6 +79,7 @@ export abstract class UnitSpawnMenu { this.#unitRoleTypeDropdown = new Dropdown(null, (roleType: string) => this.#setUnitRoleType(roleType), undefined, "Role"); this.#unitLabelDropdown = new Dropdown(null, (name: string) => this.#setUnitName(name), undefined, "Type"); this.#unitLoadoutDropdown = new Dropdown(null, (loadout: string) => this.#setUnitLoadout(loadout), undefined, "Loadout"); + this.#unitSkillDropdown = new Dropdown(null, (skill: string) => this.#setUnitSkill(skill), undefined, "Skill"); this.#unitCountDropdown = new Dropdown(null, (count: string) => this.#setUnitCount(count), undefined, "Count"); this.#unitCountryDropdown = new Dropdown(null, () => { /* Custom button implementation */ }, undefined, "Country"); this.#unitLiveryDropdown = new Dropdown(null, (livery: string) => this.#setUnitLivery(livery), undefined, "Livery"); @@ -141,7 +144,7 @@ export abstract class UnitSpawnMenu { }); /* Assemble all components */ - this.#container.append(this.#unitRoleTypeDropdown.getContainer(), unitLabelCountContainerEl, this.#unitLoadoutDropdown.getContainer(), this.#unitSpawnAltitudeSlider.getContainer() as HTMLElement, + this.#container.append(this.#unitRoleTypeDropdown.getContainer(), unitLabelCountContainerEl, this.#unitLoadoutDropdown.getContainer(), this.#unitSkillDropdown.getContainer(), this.#unitSpawnAltitudeSlider.getContainer() as HTMLElement, this.#unitLoadoutPreviewEl, this.#advancedOptionsToggle, this.#advancedOptionsDiv, this.#unitInfoToggle, this.#unitInfoDiv, this.#deployUnitButtonEl); /* Load the country codes from the public folder */ @@ -170,6 +173,7 @@ export abstract class UnitSpawnMenu { /* Hide all the other components */ this.#unitLoadoutDropdown.hide(); + this.#unitSkillDropdown.hide(); this.#unitSpawnAltitudeSlider.hide(); this.#unitLoadoutPreviewEl.classList.add("hide"); this.#advancedOptionsDiv.classList.add("hide"); @@ -244,6 +248,10 @@ export abstract class UnitSpawnMenu { this.#unitLoadoutPreviewEl.classList.remove("hide"); } + if (this.#showSkill) { + this.#unitSkillDropdown.show(); + } + /* Show the advanced options and unit info sections */ this.#advancedOptionsText.classList.remove("hide"); this.#advancedOptionsToggle.classList.remove("hide"); @@ -261,6 +269,11 @@ export abstract class UnitSpawnMenu { this.#unitLoadoutDropdown.selectValue(0); } + if (!this.#unitSkillDropdown.isHidden()) { + this.#unitSkillDropdown.setOptions(["Average", "Good", "High", "Excellent"]) + this.#unitSkillDropdown.selectValue(3); + } + /* Get the unit data from the db */ var blueprint = this.#unitDatabase.getByName(this.spawnOptions.name); @@ -317,6 +330,10 @@ export abstract class UnitSpawnMenu { this.#container.dispatchEvent(new Event("resize")); }) + this.#container.addEventListener("unitSkillChanged", () => { + + }) + this.#container.addEventListener("unitCountChanged", () => { /* Recompute the spawn points */ this.#computeSpawnPoints(); @@ -372,6 +389,7 @@ export abstract class UnitSpawnMenu { this.#unitCountDivider.classList.add("hide"); this.#unitCountDropdown.hide(); this.#unitLoadoutDropdown.hide(); + this.#unitSkillDropdown.hide(); this.#unitSpawnAltitudeSlider.hide(); this.#unitLoadoutPreviewEl.classList.add("hide"); this.#advancedOptionsDiv.classList.add("hide"); @@ -488,6 +506,10 @@ export abstract class UnitSpawnMenu { return this.#unitLoadoutDropdown; } + getSkillDropdown() { + return this.#unitSkillDropdown; + } + getCountryDropdown() { return this.#unitCountDropdown; } @@ -530,6 +552,11 @@ export abstract class UnitSpawnMenu { this.#container.dispatchEvent(new Event("unitLoadoutChanged")); } + #setUnitSkill(skill: string) { + this.spawnOptions.skill = skill; + this.#container.dispatchEvent(new Event("unitSkillChanged")); + } + #setUnitCount(count: string) { this.spawnOptions.count = parseInt(count); this.#container.dispatchEvent(new Event("unitCountChanged")); @@ -638,15 +665,16 @@ export class AircraftSpawnMenu extends UnitSpawnMenu { var unitTable: UnitSpawnTable = { unitType: spawnOptions.name, location: spawnOptions.latlng, - altitude: spawnOptions.altitude? spawnOptions.altitude: 0, - loadout: spawnOptions.loadout? spawnOptions.loadout.name: "", - liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "" + altitude: spawnOptions.altitude ? spawnOptions.altitude : 0, + loadout: spawnOptions.loadout ? spawnOptions.loadout.name : "", + liveryID: spawnOptions.liveryID ? spawnOptions.liveryID : "", + skill: spawnOptions.skill ? spawnOptions.skill : "Excellent" // Default to "Excellent" if skill is not set }; var units = []; - for (let i = 1; i < unitsCount + 1; i++) { + for (let i = 1; i <= unitsCount; i++) { units.push(unitTable); } - + getApp().getUnitsManager().spawnUnits("Aircraft", units, getApp().getActiveCoalition(), false, spawnOptions.airbase ? spawnOptions.airbase.getName() : "", spawnOptions.country, (res: any) => { if (res.commandHash !== undefined) getApp().getMap().addTemporaryMarker(spawnOptions.latlng, spawnOptions.name, getApp().getActiveCoalition(), res.commandHash); @@ -655,6 +683,7 @@ export class AircraftSpawnMenu extends UnitSpawnMenu { this.getContainer().dispatchEvent(new Event("hide")); } } + } export class HelicopterSpawnMenu extends UnitSpawnMenu { @@ -679,7 +708,8 @@ export class HelicopterSpawnMenu extends UnitSpawnMenu { location: spawnOptions.latlng, altitude: spawnOptions.altitude? spawnOptions.altitude: 0, loadout: spawnOptions.loadout? spawnOptions.loadout.name: "", - liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "" + liveryID: spawnOptions.liveryID? spawnOptions.liveryID: "", + skill: spawnOptions.skill ? spawnOptions.skill : "Excellent" // Default to "Excellent" if skill is not set }; var units = []; for (let i = 1; i < unitsCount + 1; i++) { diff --git a/client/src/interfaces.ts b/client/src/interfaces.ts index 4461a17f..5b66ceef 100644 --- a/client/src/interfaces.ts +++ b/client/src/interfaces.ts @@ -75,6 +75,7 @@ export interface UnitSpawnTable { location: LatLng, altitude?: number, loadout?: string, + skill?: string, liveryID: string } @@ -238,6 +239,7 @@ export interface UnitSpawnOptions { coalition: string; count: number; country: string; + skill: string; loadout: LoadoutBlueprint | undefined; airbase: Airbase | undefined; liveryID: string | undefined; From 4f72f10642d03fbf0a39b944f9200b9d91b9f10f Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:28:39 +0100 Subject: [PATCH 02/11] Commiting uncommited files --- backend/core/src/commands.cpp | 2 ++ backend/core/src/scheduler.cpp | 3 ++- scripts/lua/backend/OlympusCommand.lua | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/core/src/commands.cpp b/backend/core/src/commands.cpp index 377ed71f..e7579d05 100644 --- a/backend/core/src/commands.cpp +++ b/backend/core/src/commands.cpp @@ -95,6 +95,7 @@ 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 << "\"" << " }, "; } @@ -122,6 +123,7 @@ 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 << "\"" << " }, "; } diff --git a/backend/core/src/scheduler.cpp b/backend/core/src/scheduler.cpp index 42dca980..d121c00d 100644 --- a/backend/core/src/scheduler.cpp +++ b/backend/core/src/scheduler.cpp @@ -203,9 +203,10 @@ void Scheduler::handleRequest(string key, json::value value, string username, js 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 skill = to_string(unit[L"skill"]); string liveryID = to_string(unit[L"liveryID"]); - spawnOptions.push_back({unitType, location, loadout, liveryID}); + spawnOptions.push_back({unitType, location, loadout, skill, liveryID}); log(username + " spawned a " + coalition + " " + unitType, true); } diff --git a/scripts/lua/backend/OlympusCommand.lua b/scripts/lua/backend/OlympusCommand.lua index 45b366bb..e7da4ce3 100644 --- a/scripts/lua/backend/OlympusCommand.lua +++ b/scripts/lua/backend/OlympusCommand.lua @@ -600,7 +600,7 @@ function Olympus.spawnUnits(spawnTable) end -- Generates unit table for air units -function Olympus.generateAirUnitsTable(units) +function Olympus.generateAirUnitsTable(units, skill) 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) ["y"] = spawnLocation.z, ["alt"] = unit.alt, ["alt_type"] = "BARO", - ["skill"] = "Excellent", + ["skill"] = skill, ["payload"] = payload, ["heading"] = unit.heading, ["callsign"] = { [1] = 1, [2] = 1, [3] = 1, ["name"] = "Olympus" .. Olympus.unitCounter.. "-" .. #unitsTable + 1 }, From b9201d583c33161393c8e573329da6d83fb5b067 Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Thu, 11 Jan 2024 14:16:19 +0100 Subject: [PATCH 03/11] Added tiny fixed --- client/scripts/debug-nodcs.bat | 6 +++++- client/scripts/debug.bat | 4 ++++ client/src/controls/unitspawnmenu.ts | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/scripts/debug-nodcs.bat b/client/scripts/debug-nodcs.bat index 4d109cc0..300fd4e7 100644 --- a/client/scripts/debug-nodcs.bat +++ b/client/scripts/debug-nodcs.bat @@ -1,6 +1,10 @@ +cd scripts +call ./copy.bat +cd .. + REM create a "fake" dcs Saved Games folder mkdir "%temp%\DCS Olympus\dcs" echo F|xcopy /Y "..\olympus.json" "%temp%\DCS Olympus\dcs\Config\olympus.json" echo D|xcopy /Y /S /E "..\databases" "%temp%\DCS Olympus\dcs\Mods\Services\Olympus\databases" -concurrently --kill-others "node ./bin/demo --config \"%temp%\DCS Olympus\dcs\Config\olympus.json\"" "npm run watch" "nodemon --ignore ./public/databases/ ./bin/www -- --config \"%temp%\DCS Olympus\dcs\Config\olympus.json\"" \ No newline at end of file +concurrently --kill-others "node ./bin/demo --config \"%temp%\DCS Olympus\dcs\Config\olympus.json\"" "npm run watch" "nodemon --ignore ./public/databases/ ./bin/www -- --config \"%temp%\DCS Olympus\dcs\Config\olympus.json\"" \ No newline at end of file diff --git a/client/scripts/debug.bat b/client/scripts/debug.bat index ac341aa0..70a6dad9 100644 --- a/client/scripts/debug.bat +++ b/client/scripts/debug.bat @@ -1,3 +1,7 @@ @echo off +cd scripts +call ./copy.bat +cd .. + set /p "config=Enter DCS Saved Games folder location: " concurrently --kill-others "npm run watch" "nodemon --ignore ./public/databases/ ./bin/www -- --config \"%config%\Config\Olympus.json\"" \ No newline at end of file diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index 14743167..830f3224 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -39,6 +39,7 @@ export abstract class UnitSpawnMenu { #countryCodes: any; #orderByRole: boolean; #showLoadout: boolean = true; + #showSkill: boolean = true; #showAltitudeSlider: boolean = true; /* Controls */ @@ -233,6 +234,7 @@ export abstract class UnitSpawnMenu { /* Reset the spawn options */ this.spawnOptions.name = ""; this.spawnOptions.loadout = undefined; + this.spawnOptions.skill = "Excellent"; this.spawnOptions.liveryID = undefined; this.#computeSpawnPoints(); @@ -530,6 +532,10 @@ export abstract class UnitSpawnMenu { this.#showLoadout = showLoadout; } + setShowSkill(showSkill: boolean) { + this.#showSkill = showSkill + } + setShowAltitudeSlider(showAltitudeSlider: boolean) { this.#showAltitudeSlider = showAltitudeSlider; } From c042d2b6f5a15e374b50288d9e9e4e2fa0b78204 Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:37:28 +0100 Subject: [PATCH 04/11] Changes --- backend/core/include/commands.h | 8 ++++++-- backend/core/include/datatypes.h | 1 + backend/core/src/commands.cpp | 2 ++ scripts/lua/backend/OlympusCommand.lua | 10 +++++----- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/core/include/commands.h b/backend/core/include/commands.h index 2badd091..f0071562 100644 --- a/backend/core/include/commands.h +++ b/backend/core/include/commands.h @@ -211,12 +211,13 @@ private: class SpawnAircrafts : public Command { public: - SpawnAircrafts(string coalition, vector spawnOptions, string airbaseName, string country, bool immediate, function callback = [](){}) : + SpawnAircrafts(string coalition, vector spawnOptions, string airbaseName, string country, string skill, bool immediate, function callback = [](){}) : Command(callback), coalition(coalition), spawnOptions(spawnOptions), airbaseName(airbaseName), country(country), + skill(skill), immediate(immediate) { priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW; @@ -229,6 +230,7 @@ private: const vector spawnOptions; const string airbaseName; const string country; + const string skill; const bool immediate; }; @@ -236,12 +238,13 @@ private: class SpawnHelicopters : public Command { public: - SpawnHelicopters(string coalition, vector spawnOptions, string airbaseName, string country, bool immediate, function callback = [](){}) : + SpawnHelicopters(string coalition, vector spawnOptions, string airbaseName, string country, string skill, bool immediate, function callback = [](){}) : Command(callback), coalition(coalition), spawnOptions(spawnOptions), airbaseName(airbaseName), country(country), + skill(skill), immediate(immediate) { priority = immediate ? CommandPriority::IMMEDIATE : CommandPriority::LOW; @@ -254,6 +257,7 @@ private: const vector spawnOptions; const string airbaseName; const string country; + const string skill; const bool immediate; }; diff --git a/backend/core/include/datatypes.h b/backend/core/include/datatypes.h index 6dd44e85..c0e1c86e 100644 --- a/backend/core/include/datatypes.h +++ b/backend/core/include/datatypes.h @@ -152,6 +152,7 @@ struct SpawnOptions { string unitType; Coords location; string loadout; + string skill; string liveryID; }; diff --git a/backend/core/src/commands.cpp b/backend/core/src/commands.cpp index e7579d05..a0868ca1 100644 --- a/backend/core/src/commands.cpp +++ b/backend/core/src/commands.cpp @@ -106,6 +106,7 @@ string SpawnAircrafts::getString() << "coalition = " << "\"" << coalition << "\"" << ", " << "airbaseName = \"" << airbaseName << "\", " << "country = \"" << country << "\", " + << "skill = \"" << skill << "\", " << "units = " << "{" << unitsSS.str() << "}" << "}"; return commandSS.str(); } @@ -134,6 +135,7 @@ string SpawnHelicopters::getString() << "coalition = " << "\"" << coalition << "\"" << ", " << "airbaseName = \"" << airbaseName << "\", " << "country = \"" << country << "\", " + << "skill = \"" << skill << "\", " << "units = " << "{" << unitsSS.str() << "}" << "}"; return commandSS.str(); } diff --git a/scripts/lua/backend/OlympusCommand.lua b/scripts/lua/backend/OlympusCommand.lua index e7da4ce3..fcdb37eb 100644 --- a/scripts/lua/backend/OlympusCommand.lua +++ b/scripts/lua/backend/OlympusCommand.lua @@ -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) +function Olympus.spawnUnits(spawnTable, skill) Olympus.debug("Olympus.spawnUnits " .. Olympus.serializeTable(spawnTable), 2) local unitsTable = nil @@ -554,11 +554,11 @@ function Olympus.spawnUnits(spawnTable) -- Generate the units table and route as per DCS requirements if spawnTable.category == 'Aircraft' then - unitsTable = Olympus.generateAirUnitsTable(spawnTable.units) + unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill) route = Olympus.generateAirUnitsRoute(spawnTable) category = 'plane' elseif spawnTable.category == 'Helicopter' then - unitsTable = Olympus.generateAirUnitsTable(spawnTable.units) + unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill) route = Olympus.generateAirUnitsRoute(spawnTable) category = 'helicopter' elseif spawnTable.category == 'GroundUnit' then @@ -1109,9 +1109,9 @@ function Olympus.setUnitsData(arg, time) -- Generate the units table as per DCS requirements if table["category"] == 'Aircraft' then - unitsTable = Olympus.generateAirUnitsTable(spawnTable.units) + unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill) elseif table["category"] == 'Helicopter' then - unitsTable = Olympus.generateAirUnitsTable(spawnTable.units) + unitsTable = Olympus.generateAirUnitsTable(spawnTable.units, skill) elseif table["category"] == 'GroundUnit' then unitsTable = Olympus.generateGroundUnitsTable(spawnTable.units) elseif table["category"] == 'NavyUnit' then From 9942ff476b8c5cbddad458deaacc474da65c6d19 Mon Sep 17 00:00:00 2001 From: Stefan Arsic Date: Thu, 11 Jan 2024 19:41:04 +0100 Subject: [PATCH 05/11] Made the skill work --- backend/core/src/scheduler.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/core/src/scheduler.cpp b/backend/core/src/scheduler.cpp index d121c00d..b36884a5 100644 --- a/backend/core/src/scheduler.cpp +++ b/backend/core/src/scheduler.cpp @@ -191,6 +191,8 @@ 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(); if (!checkSpawnPoints(spawnPoints, coalition)) return; @@ -203,17 +205,17 @@ void Scheduler::handleRequest(string key, json::value value, string username, js 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 skill = to_string(unit[L"skill"]); string liveryID = to_string(unit[L"liveryID"]); + skill = to_string(unit[L"skill"]); - spawnOptions.push_back({unitType, location, loadout, skill, liveryID}); + spawnOptions.push_back({unitType, location, loadout, liveryID}); log(username + " spawned a " + coalition + " " + unitType, true); } if (key.compare("spawnAircrafts") == 0) - command = dynamic_cast(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, immediate)); + command = dynamic_cast(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, skill, immediate)); else - command = dynamic_cast(new SpawnHelicopters(coalition, spawnOptions, airbaseName, country, immediate)); + command = dynamic_cast(new SpawnHelicopters(coalition, spawnOptions, airbaseName, country, skill, immediate)); } /************************/ else if (key.compare("spawnGroundUnits") == 0 || key.compare("spawnNavyUnits") == 0) From 497f718e4b3ea16d5223508e8982ef3e30acd63e Mon Sep 17 00:00:00 2001 From: Stefan Arsic Date: Fri, 12 Jan 2024 22:33:43 +0100 Subject: [PATCH 06/11] Added option for ground units to change skill --- backend/core/include/commands.h | 8 ++++++-- backend/core/src/commands.cpp | 4 ++++ backend/core/src/scheduler.cpp | 6 ++++-- client/src/controls/unitspawnmenu.ts | 6 ++++-- scripts/lua/backend/OlympusCommand.lua | 20 ++++++++++---------- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/backend/core/include/commands.h b/backend/core/include/commands.h index f0071562..ac250b55 100644 --- a/backend/core/include/commands.h +++ b/backend/core/include/commands.h @@ -165,11 +165,12 @@ private: class SpawnGroundUnits : public Command { public: - SpawnGroundUnits(string coalition, vector spawnOptions, string country, bool immediate, function callback = [](){}) : + SpawnGroundUnits(string coalition, vector spawnOptions, string country, string skill, bool immediate, function 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; const string country; + const string skill; const bool immediate; }; @@ -188,11 +190,12 @@ private: class SpawnNavyUnits : public Command { public: - SpawnNavyUnits(string coalition, vector spawnOptions, string country, bool immediate, function callback = [](){}) : + SpawnNavyUnits(string coalition, vector spawnOptions, string country, string skill, bool immediate, function 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; const string country; + const string skill; const bool immediate; }; diff --git a/backend/core/src/commands.cpp b/backend/core/src/commands.cpp index a0868ca1..1529ca84 100644 --- a/backend/core/src/commands.cpp +++ b/backend/core/src/commands.cpp @@ -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(); } diff --git a/backend/core/src/scheduler.cpp b/backend/core/src/scheduler.cpp index b36884a5..83da80cc 100644 --- a/backend/core/src/scheduler.cpp +++ b/backend/core/src/scheduler.cpp @@ -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(new SpawnGroundUnits(coalition, spawnOptions, country, immediate)); + command = dynamic_cast(new SpawnGroundUnits(coalition, spawnOptions, country, skill, immediate)); else - command = dynamic_cast(new SpawnNavyUnits(coalition, spawnOptions, country, immediate)); + command = dynamic_cast(new SpawnNavyUnits(coalition, spawnOptions, country, skill, immediate)); } /************************/ else if (key.compare("attackUnit") == 0) diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index 830f3224..14751cf6 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -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 = []; diff --git a/scripts/lua/backend/OlympusCommand.lua b/scripts/lua/backend/OlympusCommand.lua index fcdb37eb..295cafae 100644 --- a/scripts/lua/backend/OlympusCommand.lua +++ b/scripts/lua/backend/OlympusCommand.lua @@ -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 From 2124e9cd42ecd257848f3e95545b5d6606b67728 Mon Sep 17 00:00:00 2001 From: Stefan Arsic Date: Sat, 3 Feb 2024 22:29:26 +0100 Subject: [PATCH 07/11] Fixed setting skill level --- backend/core/include/commands.h | 16 ++++------------ backend/core/src/commands.cpp | 21 +++++++++------------ backend/core/src/scheduler.cpp | 20 +++++++++----------- client/src/controls/unitspawnmenu.ts | 2 +- scripts/lua/backend/OlympusCommand.lua | 26 +++++++++++++------------- 5 files changed, 36 insertions(+), 49 deletions(-) diff --git a/backend/core/include/commands.h b/backend/core/include/commands.h index ac250b55..2badd091 100644 --- a/backend/core/include/commands.h +++ b/backend/core/include/commands.h @@ -165,12 +165,11 @@ private: class SpawnGroundUnits : public Command { public: - SpawnGroundUnits(string coalition, vector spawnOptions, string country, string skill, bool immediate, function callback = [](){}) : + SpawnGroundUnits(string coalition, vector spawnOptions, string country, bool immediate, function 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; const string country; - const string skill; const bool immediate; }; @@ -190,12 +188,11 @@ private: class SpawnNavyUnits : public Command { public: - SpawnNavyUnits(string coalition, vector spawnOptions, string country, string skill, bool immediate, function callback = [](){}) : + SpawnNavyUnits(string coalition, vector spawnOptions, string country, bool immediate, function 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; const string country; - const string skill; const bool immediate; }; @@ -215,13 +211,12 @@ private: class SpawnAircrafts : public Command { public: - SpawnAircrafts(string coalition, vector spawnOptions, string airbaseName, string country, string skill, bool immediate, function callback = [](){}) : + SpawnAircrafts(string coalition, vector spawnOptions, string airbaseName, string country, bool immediate, function 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; 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, string airbaseName, string country, string skill, bool immediate, function callback = [](){}) : + SpawnHelicopters(string coalition, vector spawnOptions, string airbaseName, string country, bool immediate, function 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; const string airbaseName; const string country; - const string skill; const bool immediate; }; diff --git a/backend/core/src/commands.cpp b/backend/core/src/commands.cpp index 1529ca84..604580cb 100644 --- a/backend/core/src/commands.cpp +++ b/backend/core/src/commands.cpp @@ -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(); } diff --git a/backend/core/src/scheduler.cpp b/backend/core/src/scheduler.cpp index 83da80cc..23947274 100644 --- a/backend/core/src/scheduler.cpp +++ b/backend/core/src/scheduler.cpp @@ -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(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, skill, immediate)); + command = dynamic_cast(new SpawnAircrafts(coalition, spawnOptions, airbaseName, country, immediate)); else - command = dynamic_cast(new SpawnHelicopters(coalition, spawnOptions, airbaseName, country, skill, immediate)); + command = dynamic_cast(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(new SpawnGroundUnits(coalition, spawnOptions, country, skill, immediate)); + command = dynamic_cast(new SpawnGroundUnits(coalition, spawnOptions, country, immediate)); else - command = dynamic_cast(new SpawnNavyUnits(coalition, spawnOptions, country, skill, immediate)); + command = dynamic_cast(new SpawnNavyUnits(coalition, spawnOptions, country, immediate)); } /************************/ else if (key.compare("attackUnit") == 0) diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index 14751cf6..e237afd8 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -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 */ diff --git a/scripts/lua/backend/OlympusCommand.lua b/scripts/lua/backend/OlympusCommand.lua index 295cafae..a80c205f 100644 --- a/scripts/lua/backend/OlympusCommand.lua +++ b/scripts/lua/backend/OlympusCommand.lua @@ -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 From 965b67b8ab691b11ae524db98a75c37e85af6131 Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:27:55 +0100 Subject: [PATCH 08/11] Sort SkillDropdown by Skill level --- client/src/controls/unitspawnmenu.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index e237afd8..ae8f3630 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -272,9 +272,11 @@ export abstract class UnitSpawnMenu { } if (!this.#unitSkillDropdown.isHidden()) { - this.#unitSkillDropdown.setOptions(["Average", "Good", "High", "Excellent"]) + const sortedOptions = ["Average", "Good", "High", "Excellent"]; + this.#unitSkillDropdown.setOptions(sortedOptions, null); this.#unitSkillDropdown.selectValue(4); - } + } + /* Get the unit data from the db */ var blueprint = this.#unitDatabase.getByName(this.spawnOptions.name); From 59a8fba14d16601a06ae2181cd6361ebff23dc90 Mon Sep 17 00:00:00 2001 From: Stefan Arsic <55553527+WoodyXP@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:43:24 +0100 Subject: [PATCH 09/11] Made unit.skill instead of just skill --- scripts/lua/backend/OlympusCommand.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/lua/backend/OlympusCommand.lua b/scripts/lua/backend/OlympusCommand.lua index a80c205f..390abf57 100644 --- a/scripts/lua/backend/OlympusCommand.lua +++ b/scripts/lua/backend/OlympusCommand.lua @@ -708,7 +708,7 @@ function Olympus.generateGroundUnitsTable(units) ["x"] = spawnLocation.x + value.dx, ["y"] = spawnLocation.z + value.dy, ["heading"] = 0, - ["skill"] = skill, + ["skill"] = unit.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"] = skill, + ["skill"] = unit.skill, ["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1, ["livery_id"] = unit.liveryID } @@ -742,7 +742,7 @@ function Olympus.generateNavyUnitsTable(units) ["x"] = spawnLocation.x + value.dx, ["y"] = spawnLocation.z + value.dy, ["heading"] = 0, - ["skill"] = skill, + ["skill"] = unit.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"] = skill, + ["skill"] = unit.skill, ["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1, ["transportable"] = { ["randomTransportable"] = false }, ["livery_id"] = unit.liveryID From 5765ade7f88535f0128423383d8a6ef2d7746308 Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:11:16 +0100 Subject: [PATCH 10/11] Change the location of the skill select --- client/src/controls/unitspawnmenu.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index ae8f3630..758bd611 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -108,14 +108,14 @@ export abstract class UnitSpawnMenu { this.#advancedOptionsToggle = document.createElement("div"); this.#advancedOptionsToggle.classList.add("contextmenu-advanced-options-toggle"); this.#advancedOptionsText = document.createElement("div"); - this.#advancedOptionsText.innerText = "Faction / Liveries"; + this.#advancedOptionsText.innerText = "Faction / Liveries / Skill Level"; this.#advancedOptionsToggle.append(this.#advancedOptionsText); this.#advancedOptionsToggle.addEventListener("click", () => { this.#advancedOptionsToggle.classList.toggle("is-open"); this.#advancedOptionsDiv.classList.toggle("hide"); this.#container.dispatchEvent(new Event("resize")); }); - this.#advancedOptionsDiv.append(this.#unitCountryDropdown.getContainer(), this.#unitLiveryDropdown.getContainer()); + this.#advancedOptionsDiv.append(this.#unitCountryDropdown.getContainer(), this.#unitLiveryDropdown.getContainer(), this.#unitSkillDropdown.getContainer()); /* Create the unit info collapsible div */ this.#unitInfoDiv = document.createElement("div"); @@ -145,7 +145,7 @@ export abstract class UnitSpawnMenu { }); /* Assemble all components */ - this.#container.append(this.#unitRoleTypeDropdown.getContainer(), unitLabelCountContainerEl, this.#unitLoadoutDropdown.getContainer(), this.#unitSkillDropdown.getContainer(), this.#unitSpawnAltitudeSlider.getContainer() as HTMLElement, + this.#container.append(this.#unitRoleTypeDropdown.getContainer(), unitLabelCountContainerEl, this.#unitLoadoutDropdown.getContainer(), this.#unitSpawnAltitudeSlider.getContainer() as HTMLElement, this.#unitLoadoutPreviewEl, this.#advancedOptionsToggle, this.#advancedOptionsDiv, this.#unitInfoToggle, this.#unitInfoDiv, this.#deployUnitButtonEl); /* Load the country codes from the public folder */ From b5c7eaf36ed68d65d027454136c8cf77ae2100de Mon Sep 17 00:00:00 2001 From: WoodyXP <55553527+WoodyXP@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:36:22 +0100 Subject: [PATCH 11/11] Change the name of default livery --- client/src/controls/unitspawnmenu.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/controls/unitspawnmenu.ts b/client/src/controls/unitspawnmenu.ts index 758bd611..5a1ec487 100644 --- a/client/src/controls/unitspawnmenu.ts +++ b/client/src/controls/unitspawnmenu.ts @@ -577,7 +577,7 @@ export abstract class UnitSpawnMenu { #setUnitLivery(liveryName: string) { var liveries = this.#unitDatabase.getByName(this.spawnOptions.name)?.liveries; - if (liveryName === "Default") { + if (liveryName === "Default Livery") { this.spawnOptions.liveryID = ""; } else { @@ -593,7 +593,7 @@ export abstract class UnitSpawnMenu { #setUnitLiveryOptions() { if (this.spawnOptions.name !== "" && this.spawnOptions.country !== "") { var liveries = this.#unitDatabase.getLiveryNamesByName(this.spawnOptions.name); - var countryLiveries: string[] = ["Default"]; + var countryLiveries: string[] = ["Default Livery"]; liveries.forEach((livery: any) => { var nationLiveryCodes = this.#countryCodes[this.spawnOptions.country].liveryCodes; if (livery.countries === "All" || livery.countries.some((country: string) => { return nationLiveryCodes.includes(country) }))