mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge pull request #821 from WoodyXP/681_newest_changes_skill
681 newest changes skill
This commit is contained in:
commit
63bdf44e17
@ -152,6 +152,7 @@ struct SpawnOptions {
|
||||
string unitType;
|
||||
Coords location;
|
||||
string loadout;
|
||||
string skill;
|
||||
string liveryID;
|
||||
};
|
||||
|
||||
|
||||
@ -46,7 +46,9 @@ string SpawnGroundUnits::getString()
|
||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
@ -70,7 +72,8 @@ string SpawnNavyUnits::getString()
|
||||
<< "unitType = " << "\"" << spawnOptions[i].unitType << "\"" << ", "
|
||||
<< "lat = " << spawnOptions[i].location.lat << ", "
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
@ -95,7 +98,8 @@ string SpawnAircrafts::getString()
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "alt = " << spawnOptions[i].location.alt << ", "
|
||||
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
@ -122,7 +126,8 @@ string SpawnHelicopters::getString()
|
||||
<< "lng = " << spawnOptions[i].location.lng << ", "
|
||||
<< "alt = " << spawnOptions[i].location.alt << ", "
|
||||
<< "loadout = \"" << spawnOptions[i].loadout << "\"" << ", "
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << " }, ";
|
||||
<< "liveryID = " << "\"" << spawnOptions[i].liveryID << "\"" << ", "
|
||||
<< "skill = \"" << spawnOptions[i].skill << "\"" << "}, ";
|
||||
}
|
||||
|
||||
std::ostringstream commandSS;
|
||||
|
||||
@ -192,6 +192,7 @@ void Scheduler::handleRequest(string key, json::value value, string username, js
|
||||
string airbaseName = to_string(value[L"airbaseName"]);
|
||||
string country = to_string(value[L"country"]);
|
||||
|
||||
|
||||
int spawnPoints = value[L"spawnPoints"].as_number().to_int32();
|
||||
if (!checkSpawnPoints(spawnPoints, coalition)) return;
|
||||
|
||||
@ -204,9 +205,10 @@ 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"]);
|
||||
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)
|
||||
@ -231,8 +233,9 @@ 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"]);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
2
client/@types/olympus/index.d.ts
vendored
2
client/@types/olympus/index.d.ts
vendored
@ -653,6 +653,7 @@ declare module "interfaces" {
|
||||
coalition: string;
|
||||
count: number;
|
||||
country: string;
|
||||
skill: string;
|
||||
loadout: LoadoutBlueprint | undefined;
|
||||
airbase: Airbase | undefined;
|
||||
liveryID: string | undefined;
|
||||
@ -900,6 +901,7 @@ declare module "controls/unitspawnmenu" {
|
||||
getLabelDropdown(): Dropdown;
|
||||
getCountDropdown(): Dropdown;
|
||||
getLoadoutDropdown(): Dropdown;
|
||||
getSkillDropdown(): Dropdown;
|
||||
getCountryDropdown(): Dropdown;
|
||||
getLiveryDropdown(): Dropdown;
|
||||
getLoadoutPreview(): HTMLDivElement;
|
||||
|
||||
@ -7,4 +7,4 @@ 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\""
|
||||
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\""
|
||||
@ -27,6 +27,7 @@ export abstract class UnitSpawnMenu {
|
||||
coalition: "blue",
|
||||
count: 1,
|
||||
country: "",
|
||||
skill: "Excellent",
|
||||
loadout: undefined,
|
||||
airbase: undefined,
|
||||
liveryID: undefined,
|
||||
@ -38,6 +39,7 @@ export abstract class UnitSpawnMenu {
|
||||
#countryCodes: any;
|
||||
#orderByRole: boolean;
|
||||
#showLoadout: boolean = true;
|
||||
#showSkill: boolean = true;
|
||||
#showAltitudeSlider: boolean = true;
|
||||
|
||||
/* Controls */
|
||||
@ -45,6 +47,7 @@ export abstract class UnitSpawnMenu {
|
||||
#unitLabelDropdown: Dropdown;
|
||||
#unitCountDropdown: Dropdown;
|
||||
#unitLoadoutDropdown: Dropdown;
|
||||
#unitSkillDropdown: Dropdown;
|
||||
#unitCountryDropdown: Dropdown;
|
||||
#unitLiveryDropdown: Dropdown;
|
||||
#unitSpawnAltitudeSlider: Slider;
|
||||
@ -77,6 +80,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");
|
||||
@ -104,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");
|
||||
@ -170,6 +174,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");
|
||||
@ -229,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();
|
||||
@ -244,6 +250,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 +271,13 @@ export abstract class UnitSpawnMenu {
|
||||
this.#unitLoadoutDropdown.selectValue(0);
|
||||
}
|
||||
|
||||
if (!this.#unitSkillDropdown.isHidden()) {
|
||||
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);
|
||||
|
||||
@ -317,6 +334,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 +393,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 +510,10 @@ export abstract class UnitSpawnMenu {
|
||||
return this.#unitLoadoutDropdown;
|
||||
}
|
||||
|
||||
getSkillDropdown() {
|
||||
return this.#unitSkillDropdown;
|
||||
}
|
||||
|
||||
getCountryDropdown() {
|
||||
return this.#unitCountDropdown;
|
||||
}
|
||||
@ -508,6 +534,10 @@ export abstract class UnitSpawnMenu {
|
||||
this.#showLoadout = showLoadout;
|
||||
}
|
||||
|
||||
setShowSkill(showSkill: boolean) {
|
||||
this.#showSkill = showSkill
|
||||
}
|
||||
|
||||
setShowAltitudeSlider(showAltitudeSlider: boolean) {
|
||||
this.#showAltitudeSlider = showAltitudeSlider;
|
||||
}
|
||||
@ -530,6 +560,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"));
|
||||
@ -542,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 {
|
||||
@ -558,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) }))
|
||||
@ -638,15 +673,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 +691,7 @@ export class AircraftSpawnMenu extends UnitSpawnMenu {
|
||||
this.getContainer().dispatchEvent(new Event("hide"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class HelicopterSpawnMenu extends UnitSpawnMenu {
|
||||
@ -679,7 +716,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++) {
|
||||
@ -718,7 +756,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 = [];
|
||||
@ -768,7 +807,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 = [];
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -628,7 +628,7 @@ function Olympus.generateAirUnitsTable(units)
|
||||
["y"] = spawnLocation.z,
|
||||
["alt"] = unit.alt,
|
||||
["alt_type"] = "BARO",
|
||||
["skill"] = "Excellent",
|
||||
["skill"] = unit.skill,
|
||||
["payload"] = payload,
|
||||
["heading"] = unit.heading,
|
||||
["callsign"] = { [1] = 1, [2] = 1, [3] = 1, ["name"] = "Olympus" .. Olympus.unitCounter.. "-" .. #unitsTable + 1 },
|
||||
@ -708,7 +708,7 @@ function Olympus.generateGroundUnitsTable(units)
|
||||
["x"] = spawnLocation.x + value.dx,
|
||||
["y"] = spawnLocation.z + value.dy,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High",
|
||||
["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"] = "High",
|
||||
["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"] = "High",
|
||||
["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"] = "High",
|
||||
["skill"] = unit.skill,
|
||||
["name"] = "Olympus-" .. Olympus.unitCounter .. "-" .. #unitsTable + 1,
|
||||
["transportable"] = { ["randomTransportable"] = false },
|
||||
["livery_id"] = unit.liveryID
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user