Basic scenic and miss on purpose AAA modes

This commit is contained in:
Pax1601
2023-10-01 19:15:56 +02:00
parent d209f98265
commit 5035c408e7
10 changed files with 226 additions and 6 deletions

View File

@@ -329,6 +329,18 @@ export class ServerManager {
this.PUT(data, callback);
}
scenicAAA(ID: number, callback: CallableFunction = () => {}) {
var command = { "ID": ID }
var data = { "scenicAAA": command }
this.PUT(data, callback);
}
missOnPurpose(ID: number, callback: CallableFunction = () => {}) {
var command = { "ID": ID }
var data = { "missOnPurpose": command }
this.PUT(data, callback);
}
setAdvacedOptions(ID: number, isTanker: boolean, isAWACS: boolean, TACAN: TACAN, radio: Radio, generalSettings: GeneralSettings, callback: CallableFunction = () => {}) {
var command = {
"ID": ID,

View File

@@ -739,6 +739,15 @@ export class Unit extends CustomMarker {
});
}
scenicAAA() {
getApp().getServerManager().scenicAAA(this.ID);
}
missOnPurpose() {
getApp().getServerManager().missOnPurpose(this.ID);
}
/***********************************************/
onAdd(map: Map): this {
super.onAdd(map);
@@ -802,7 +811,7 @@ export class Unit extends CustomMarker {
if (selectedUnits.length > 0 && !(selectedUnits.length == 1 && (selectedUnits.includes(this)))) {
options["attack"] = { text: "Attack", tooltip: "Attack the unit using A/A or A/G weapons" };
if (getApp().getUnitsManager().getSelectedUnitsCategories().length == 1 && getApp().getUnitsManager().getSelectedUnitsCategories()[0] === "Aircraft")
options["follow"] = { text: "Follow", tooltip: "Follow the unit at a user defined distance and position" };;
options["follow"] = { text: "Follow", tooltip: "Follow the unit at a user defined distance and position" };
}
else if ((selectedUnits.length > 0 && (selectedUnits.includes(this))) || selectedUnits.length == 0) {
if (this.getCategory() == "Aircraft") {
@@ -813,6 +822,11 @@ export class Unit extends CustomMarker {
if (selectedUnitTypes.length === 1 && ["NavyUnit", "GroundUnit"].includes(selectedUnitTypes[0]) && getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getCoalition()}) !== undefined)
options["group"] = { text: "Create group", tooltip: "Create a group from the selected units." };
if (selectedUnitTypes.length === 1 && ["GroundUnit"].includes(selectedUnitTypes[0]) && selectedUnits.every((unit: Unit) => { return ["AAA"].includes(unit.getType())})) {
options["scenic-aaa"] = { text: "Scenic AAA", tooltip: "Shoot AAA in the air without aiming at any target" };
options["miss-aaa"] = { text: "Miss on purpose AAA", tooltip: "Shoot AAA towards the closes enemy, but don't aim precisely" };
}
if (Object.keys(options).length > 0) {
getApp().getMap().showUnitContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng);
getApp().getMap().getUnitContextMenu().setOptions(options, (option: string) => {
@@ -831,6 +845,10 @@ export class Unit extends CustomMarker {
getApp().getUnitsManager().selectedUnitsRefuel();
else if (action === "group")
getApp().getUnitsManager().selectedUnitsCreateGroup();
else if (action === "scenic-aaa")
getApp().getUnitsManager().selectedUnitsScenicAAA();
else if (action === "miss-aaa")
getApp().getUnitsManager().selectedUnitsMissOnPurpose();
else if (action === "follow")
this.#showFollowOptions(e);
}

View File

@@ -625,6 +625,26 @@ export class UnitsManager {
});
this.#showActionMessage(selectedUnits, `unit simulating fire fight`);
}
/** Instruct units to enter into scenic AAA mode. Units will shoot in the air without aiming
*
*/
selectedUnitsScenicAAA() {
var selectedUnits = this.getSelectedUnits({ excludeHumans: true, onlyOnePerGroup: true });
for (let idx in selectedUnits) {
selectedUnits[idx].scenicAAA();
}
}
/** Instruct units to enter into miss on purpose mode. Units will aim to the nearest enemy unit but not precisely.
*
*/
selectedUnitsMissOnPurpose() {
var selectedUnits = this.getSelectedUnits({ excludeHumans: true, onlyOnePerGroup: true });
for (let idx in selectedUnits) {
selectedUnits[idx].missOnPurpose();
}
}
/*********************** Control operations on selected units ************************/
/** See getUnitsCategories for more info