mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added basic template spawning
This commit is contained in:
parent
0b490e4ce2
commit
10d250e3a5
@ -322,7 +322,7 @@ export class AircraftDatabase extends UnitDatabase {
|
||||
},
|
||||
"H-6J": {
|
||||
"name": "H-6J",
|
||||
"label": "H-6J Badger,
|
||||
"label": "H-6J Badger",
|
||||
"era": ["Mid Cold War, Late Cold War", "Modern"],
|
||||
"shortLabel": "H6",
|
||||
"loadouts": [
|
||||
|
||||
@ -4,6 +4,24 @@ export class GroundUnitsDatabase extends UnitDatabase {
|
||||
constructor() {
|
||||
super();
|
||||
this.blueprints = {
|
||||
"SA-2 SAM Battery": {
|
||||
"name": "SA-2 SAM Battery",
|
||||
"label": "SA-2 SAM Battery",
|
||||
"shortLabel": "SA-2 SAM Battery",
|
||||
"loadouts": [
|
||||
{
|
||||
"fuel": 1,
|
||||
"items": [
|
||||
],
|
||||
"roles": [
|
||||
"Template"
|
||||
],
|
||||
"code": "",
|
||||
"name": "Default"
|
||||
}
|
||||
],
|
||||
"filename": ""
|
||||
},
|
||||
"2B11 mortar": {
|
||||
"name": "2B11 mortar",
|
||||
"label": "2B11 mortar",
|
||||
|
||||
@ -646,27 +646,25 @@ export class Unit extends Marker {
|
||||
}
|
||||
|
||||
#drawTargets() {
|
||||
for (let typeIndex in this.getMissionData().targets) {
|
||||
for (let index in this.getMissionData().targets[typeIndex]) {
|
||||
var targetData = this.getMissionData().targets[typeIndex][index];
|
||||
var target = getUnitsManager().getUnitByID(targetData.object["id_"])
|
||||
if (target != null) {
|
||||
var startLatLng = new LatLng(this.getFlightData().latitude, this.getFlightData().longitude)
|
||||
var endLatLng = new LatLng(target.getFlightData().latitude, target.getFlightData().longitude)
|
||||
for (let index in this.getMissionData().targets) {
|
||||
var targetData = this.getMissionData().targets[index];
|
||||
var target = getUnitsManager().getUnitByID(targetData.object["id_"])
|
||||
if (target != null) {
|
||||
var startLatLng = new LatLng(this.getFlightData().latitude, this.getFlightData().longitude)
|
||||
var endLatLng = new LatLng(target.getFlightData().latitude, target.getFlightData().longitude)
|
||||
|
||||
var color;
|
||||
if (typeIndex === "radar")
|
||||
color = "#FFFF00";
|
||||
else if (typeIndex === "visual")
|
||||
color = "#FF00FF";
|
||||
else if (typeIndex === "rwr")
|
||||
color = "#00FF00";
|
||||
else
|
||||
color = "#FFFFFF";
|
||||
var targetPolyline = new Polyline([startLatLng, endLatLng], { color: color, weight: 3, opacity: 0.4, smoothFactor: 1 });
|
||||
targetPolyline.addTo(getMap());
|
||||
this.#targetsPolylines.push(targetPolyline)
|
||||
}
|
||||
var color;
|
||||
if (targetData.detectionMethod === "RADAR")
|
||||
color = "#FFFF00";
|
||||
else if (targetData.detectionMethod === "VISUAL")
|
||||
color = "#FF00FF";
|
||||
else if (targetData.detectionMethod === "RWR")
|
||||
color = "#00FF00";
|
||||
else
|
||||
color = "#FFFFFF";
|
||||
var targetPolyline = new Polyline([startLatLng, endLatLng], { color: color, weight: 3, opacity: 0.4, smoothFactor: 1 });
|
||||
targetPolyline.addTo(getMap());
|
||||
this.#targetsPolylines.push(targetPolyline)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ export class UnitsManager {
|
||||
}
|
||||
|
||||
update(data: UnitsData) {
|
||||
var updatedUnits: Unit[] = [];
|
||||
Object.keys(data.units)
|
||||
.filter((ID: string) => !(ID in this.#units))
|
||||
.reduce((timeout: number, ID: string) => {
|
||||
@ -75,7 +76,15 @@ export class UnitsManager {
|
||||
|
||||
Object.keys(data.units)
|
||||
.filter((ID: string) => ID in this.#units)
|
||||
.forEach((ID: string) => this.#units[parseInt(ID)]?.setData(data.units[ID]));
|
||||
.forEach((ID: string) => {
|
||||
updatedUnits.push(this.#units[parseInt(ID)]);
|
||||
this.#units[parseInt(ID)]?.setData(data.units[ID])
|
||||
});
|
||||
|
||||
this.getSelectedUnits().forEach((unit: Unit) => {
|
||||
if (!updatedUnits.includes(unit))
|
||||
unit.setData({})
|
||||
});
|
||||
}
|
||||
|
||||
selectUnit(ID: number, deselectAllUnits: boolean = true) {
|
||||
|
||||
@ -22,7 +22,7 @@ Source: "..\scripts\OlympusHook.lua"; DestDir: "{app}\Scripts\Hooks"; Flags: ign
|
||||
Source: "..\olympus.json"; DestDir: "{app}\Mods\Services\Olympus"; Flags: onlyifdoesntexist
|
||||
Source: "..\scripts\OlympusCommand.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\scripts\unitPayloads.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
;Source: "..\scripts\OlympusMission.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\scripts\templates.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\scripts\mist.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\mod\*"; DestDir: "{app}\Mods\Services\Olympus"; Flags: ignoreversion recursesubdirs;
|
||||
Source: "..\bin\*.dll"; DestDir: "{app}\Mods\Services\Olympus\bin"; Flags: ignoreversion;
|
||||
|
||||
@ -232,17 +232,34 @@ end
|
||||
function Olympus.spawnGroundUnit(coalition, unitType, lat, lng)
|
||||
Olympus.debug("Olympus.spawnGroundUnit " .. coalition .. " " .. unitType .. " (" .. lat .. ", " .. lng ..")", 2)
|
||||
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(lat, lng, 0))
|
||||
local unitTable =
|
||||
{
|
||||
[1] =
|
||||
|
||||
local unitTable = {}
|
||||
|
||||
if Olympus.hasKey(templates, unitType) then
|
||||
for idx, value in pairs(templates[unitType].units) do
|
||||
unitTable[#unitTable + 1] = {
|
||||
["type"] = value.name,
|
||||
["x"] = spawnLocation.x + value.dx,
|
||||
["y"] = spawnLocation.z + value.dy,
|
||||
["playerCanDrive"] = true,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High"
|
||||
}
|
||||
end
|
||||
else
|
||||
unitTable =
|
||||
{
|
||||
["type"] = unitType,
|
||||
["x"] = spawnLocation.x,
|
||||
["y"] = spawnLocation.z,
|
||||
["playerCanDrive"] = true,
|
||||
["heading"] = 0,
|
||||
},
|
||||
}
|
||||
[1] =
|
||||
{
|
||||
["type"] = unitType,
|
||||
["x"] = spawnLocation.x,
|
||||
["y"] = spawnLocation.z,
|
||||
["playerCanDrive"] = true,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High"
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local countryID = Olympus.getCountryIDByCoalition(coalition)
|
||||
|
||||
@ -475,7 +492,26 @@ function Olympus.isArray(t)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function Olympus.hasValue(tab, val)
|
||||
for index, value in ipairs(tab) do
|
||||
if value == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function Olympus.hasKey(tab, key)
|
||||
for k, value in pairs(tab) do
|
||||
if k == key then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function Olympus.setMissionData(arg, time)
|
||||
local missionData = {}
|
||||
@ -503,14 +539,27 @@ function Olympus.setMissionData(arg, time)
|
||||
if groupName ~= nil then
|
||||
local group = Group.getByName(groupName)
|
||||
if group ~= nil then
|
||||
-- Get the targets detected by the group controller
|
||||
local controller = group:getController()
|
||||
local controllerTargets = controller:getDetectedTargets()
|
||||
|
||||
for index, unit in pairs(group:getUnits()) do
|
||||
local unitController = unit:getController()
|
||||
local table = {}
|
||||
table["targets"] = {}
|
||||
table["targets"]["visual"] = controller:getDetectedTargets(1)
|
||||
table["targets"]["radar"] = controller:getDetectedTargets(4)
|
||||
table["targets"]["rwr"] = controller:getDetectedTargets(16)
|
||||
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
|
||||
|
||||
for i, target in ipairs(controllerTargets) do
|
||||
for det, enum in pairs(Controller.Detection) do
|
||||
if target.object ~= nil then
|
||||
local detected = unitController:isTargetDetected(target.object, enum)
|
||||
|
||||
if detected then
|
||||
target["detectionMethod"] = det
|
||||
table["targets"][#table["targets"] + 1] = target
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table["hasTask"] = controller:hasTask()
|
||||
|
||||
|
||||
1354
scripts/templates.lua
Normal file
1354
scripts/templates.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -50,4 +50,5 @@ void registerLuaFunctions(lua_State* L)
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\mist.lua");
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\OlympusCommand.lua");
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\unitPayloads.lua");
|
||||
executeLuaScript(L, modLocation + "\\Scripts\\templates.lua");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user