Init files

This commit is contained in:
2025-02-24 19:02:21 +08:00
commit 774a4784f6
8 changed files with 11455 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
script_path = lfs.writedir() .. "Missions\\Buta\\Buta-017-NewMission\\Scripts\\"
if lfs then
dofile(script_path..'Mission_Init.lua')
env.info("Script Loader: LFS available, using relative script load path: " .. script_path)
else
env.info("Script Loader: LFS not available, using default script load path: " .. script_path)
end
+17
View File
@@ -0,0 +1,17 @@
local script_list =
{
-- Load order must be correct
-- "mist.lua", --mist_4_5_122
-- "Moose_.lua",
'mist_4_5_126.lua',
'Utils.lua',
'new.lua',
}
local function load_scripts(path, list)
for index, value in ipairs(list) do
dofile(path .. value)
end
end
load_scripts(script_path, script_list)
+555
View File
@@ -0,0 +1,555 @@
Utils = {
MapMarkIDs = {
[1] = true,
},
}
do
function Utils.getMarkID()
local result = nil
for i,value in ipairs(Utils.MapMarkIDs) do
if value then
result = i
Utils.MapMarkIDs[i] = false
break
end
end
if not result then
result = #Utils.MapMarkIDs + 1
Utils.MapMarkIDs[result] = false
end
return result
end
function Utils.Debug(text,displayTime,clearview)
if not text then text = 'nil or false' end
if type(text) ~= 'string' then
if type(text) ~= 'table' then
text = tostring(text)
end
if type(text) == 'table' then
if mist then
text = mist.utils.tableShow(text)
else
text = 'no mist, please use mist to debug a table.'
end
end
end
displayTime = displayTime or 10
clearview = clearview or false
trigger.action.outText(text,displayTime,clearview)
end
function Utils.getTableSize(table)
local tableSize = 0
for _,_ in pairs(table) do
tableSize = tableSize + 1
end
return tableSize
end
--- Creates a deep copy of a object.
-- Usually this object is a table.
-- See also: from http://lua-users.org/wiki/CopyTable
-- @param object object to copy
-- @return copy of object
function Utils.deepCopy(object)
local lookup_table = {}
local function _copy(object)
if type(object) ~= "table" then
return object
elseif lookup_table[object] then
return lookup_table[object]
end
local new_table = {}
lookup_table[object] = new_table
for index, value in pairs(object) do
new_table[_copy(index)] = _copy(value)
end
return setmetatable(new_table, getmetatable(object))
end
return _copy(object)
end
--- Vector addition.
-- @tparam Vec3 vec1 first vector
-- @tparam Vec3 vec2 second vector
-- @treturn Vec3 new vector, sum of vec1 and vec2.
function Utils.vecAdd(vec1, vec2)
return {x = vec1.x + vec2.x, y = vec1.y + vec2.y, z = vec1.z + vec2.z}
end
--- Vector substraction.
-- @tparam Vec3 vec1 first vector
-- @tparam Vec3 vec2 second vector
-- @treturn Vec3 new vector, vec2 substracted from vec1.
function Utils.vecSub(vec1, vec2)
return {x = vec1.x - vec2.x, y = vec1.y - vec2.y, z = vec1.z - vec2.z}
end
function Utils.vecTranslate(vec3,degree,distance)
local point = {x = vec3.x,y = vec3.z or vec3.y,}
if distance == 0 then return point end
local radian = math.rad(degree)
point.x = point.x + distance * math.cos(radian)
point.y = point.y + distance * math.sin(radian)
return point
end
function Utils.makeVec3(vec,AGL)
local result = Utils.deepCopy(vec)
if not vec.z then
result.z = vec.y
result.y = 0
if AGL then
result.y = land.getHeight(vec)
end
end
return result
end
--- Vector magnitude
-- @tparam Vec3 vec vector
-- @treturn number magnitude of vector vec
function Utils.mag(vec)
return (vec.x^2 + vec.y^2 + vec.z^2)^0.5
end
--- Returns distance in meters between two points.
-- @tparam Vec2|Vec3 point1 first point
-- @tparam Vec2|Vec3 point2 second point
-- @treturn number distance between given points.
function Utils.get2DDist(point1, point2)
if not point1 then
log:warn("Utils.get2DDist 1st input value is nil")
end
if not point2 then
log:warn("Utils.get2DDist 2nd input value is nil")
end
point1 = Utils.makeVec3(point1)
point2 = Utils.makeVec3(point2)
return Utils.mag({x = point1.x - point2.x, y = 0, z = point1.z - point2.z})
end
-- @return radians
function Utils.getObjHeading(object)
if not object then return false end
local objectPos = object:getPosition()
local objectHeading = math.atan2(objectPos.x.z, objectPos.x.x)
return objectHeading
end
function Utils.getNorthCorrection(gPoint) --gets the correction needed for true north
local point = Utils.deepCopy(gPoint)
if not point.z then --Vec2; convert to Vec3
point.z = point.y
point.y = 0
end
local lat, lon = coord.LOtoLL(point)
local north_posit = coord.LLtoLO(lat + 1, lon)
return math.atan2(north_posit.z - point.z, north_posit.x - point.x)
end
--- Returns heading-error corrected direction.
-- True-north corrected direction from point along vector vec.
-- @tparam Vec3 vec
-- @tparam Vec2 point
-- @return heading-error corrected direction from point.
function Utils.getDir(vec, point)
local dir = math.atan2(vec.z, vec.x)
if point then
dir = dir + Utils.getNorthCorrection(point)
end
if dir < 0 then
dir = dir + 2 * math.pi -- put dir in range of 0 to 2*pi
end
return dir
end
function Utils.getDirection(vec3_1,vec3_2)
local p1 = Utils.makeVec3(vec3_1,true)
local p2 = Utils.makeVec3(vec3_2,true)
local dir = Utils.getDir(Utils.vecSub(p1, p2))
return dir
end
function Utils.getAvgPoint(points)
local avgX, avgY, avgZ, totNum = 0, 0, 0, 0
for i = 1, #points do
--log:warn(points[i])
local nPoint = Utils.makeVec3(points[i])
if nPoint.z then
avgX = avgX + nPoint.x
avgY = avgY + nPoint.y
avgZ = avgZ + nPoint.z
totNum = totNum + 1
end
end
if totNum ~= 0 then
return {x = avgX/totNum, y = avgY/totNum, z = avgZ/totNum}
end
end
-- need to return a Vec3 or Vec2?
function Utils.getRandPointInCircle(p, r, innerRadius, maxA, minA)
local point = Utils.makeVec3(p)
local theta = 2*math.pi*math.random()
local radius = r or 1000
local minR = innerRadius or 0
if maxA and not minA then
theta = math.rad(math.random(0, maxA - math.random()))
elseif maxA and minA then
if minA < maxA then
theta = math.rad(math.random(minA, maxA) - math.random())
else
theta = math.rad(math.random(maxA, minA) - math.random())
end
end
local rad = math.random() + math.random()
if rad > 1 then
rad = 2 - rad
end
local radMult
if minR and minR <= radius then
--radMult = (radius - innerRadius)*rad + innerRadius
radMult = radius * math.sqrt((minR^2 + (radius^2 - minR^2) * math.random()) / radius^2)
else
radMult = radius*rad
end
local rndCoord
if radius > 0 then
rndCoord = {x = math.cos(theta)*radMult + point.x, y = math.sin(theta)*radMult + point.z}
else
rndCoord = {x = point.x, y = point.z}
end
return rndCoord
end
function Utils.getRandomPointInPoly(zone)
--env.info('Zone Size: '.. #zone)
local avg = Utils.getAvgPoint(zone)
--log:warn(avg)
local radius = 0
local minR = math.huge
local newCoord = {}
for i = 1, #zone do
if Utils.get2DDist(avg, zone[i]) > radius then
radius = Utils.get2DDist(avg, zone[i])
end
if Utils.get2DDist(avg, zone[i]) < minR then
minR = Utils.get2DDist(avg, zone[i])
end
end
--log:warn('minR: $1', minR)
--log:warn('Radius: $1', radius)
local lSpawnPos = {}
for j = 1, 100 do
newCoord = Utils.getRandPointInCircle(avg, radius)
if Utils.pointInPolygon(newCoord, zone) then
break
end
if j == 100 then
newCoord = Utils.getRandPointInCircle(avg, radius)
log:warn("Failed to find point in poly; Giving random point from center of the poly")
end
end
return newCoord
end
--- Simple rounding function.
-- From http://lua-users.org/wiki/SimpleRound
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
-- @tparam number num number to round
-- @param idp
function Utils.round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
--[[acc:
in DM: decimal point of minutes.
In DMS: decimal point of seconds.
position after the decimal of the least significant digit:
So:
42.32 - acc of 2.
]]
function Utils.tostringLL(lat, lon, acc, DMS)
local latHemi, lonHemi
if lat > 0 then
latHemi = 'N'
else
latHemi = 'S'
end
if lon > 0 then
lonHemi = 'E'
else
lonHemi = 'W'
end
lat = math.abs(lat)
lon = math.abs(lon)
local latDeg = math.floor(lat)
local latMin = (lat - latDeg)*60
local lonDeg = math.floor(lon)
local lonMin = (lon - lonDeg)*60
if DMS then -- degrees, minutes, and seconds.
local oldLatMin = latMin
latMin = math.floor(latMin)
local latSec = Utils.round((oldLatMin - latMin)*60, acc)
local oldLonMin = lonMin
lonMin = math.floor(lonMin)
local lonSec = Utils.round((oldLonMin - lonMin)*60, acc)
if latSec == 60 then
latSec = 0
latMin = latMin + 1
end
if lonSec == 60 then
lonSec = 0
lonMin = lonMin + 1
end
local secFrmtStr -- create the formatting string for the seconds place
if acc <= 0 then -- no decimal place.
secFrmtStr = '%02d'
else
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
secFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
end
return string.format('%02d', latDeg) .. ' ' .. string.format('%02d', latMin) .. '\' ' .. string.format(secFrmtStr, latSec) .. '"' .. latHemi .. ' '
.. string.format('%02d', lonDeg) .. ' ' .. string.format('%02d', lonMin) .. '\' ' .. string.format(secFrmtStr, lonSec) .. '"' .. lonHemi
else -- degrees, decimal minutes.
latMin = Utils.round(latMin, acc)
lonMin = Utils.round(lonMin, acc)
if latMin == 60 then
latMin = 0
latDeg = latDeg + 1
end
if lonMin == 60 then
lonMin = 0
lonDeg = lonDeg + 1
end
local minFrmtStr -- create the formatting string for the minutes place
if acc <= 0 then -- no decimal place.
minFrmtStr = '%02d'
else
local width = 3 + acc -- 01.310 - that's a width of 6, for example.
minFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
end
return string.format('%02d', latDeg) .. ' ' .. string.format(minFrmtStr, latMin) .. '\'' .. latHemi .. ' '
.. string.format('%02d', lonDeg) .. ' ' .. string.format(minFrmtStr, lonMin) .. '\'' .. lonHemi
end
end
--- Converts a TACAN Channel/Mode couple into a frequency in Hz.
-- @param #number TACANChannel The TACAN channel, i.e. the 10 in "10X".
-- @param #string TACANMode The TACAN mode, i.e. the "X" in "10X".
-- @return #number Frequency in Hz or #nil if parameters are invalid.
function Utils.TACANToFrequency(TACANChannel, TACANMode)
if type(TACANChannel) ~= "number" then
return nil -- error in arguments
end
if TACANMode ~= "X" and TACANMode ~= "Y" then
return nil -- error in arguments
end
-- This code is largely based on ED's code, in DCS World\Scripts\World\Radio\BeaconTypes.lua, line 137.
-- I have no idea what it does but it seems to work
local A = 1151 -- 'X', channel >= 64
local B = 64 -- channel >= 64
if TACANChannel < 64 then
B = 1
end
if TACANMode == 'Y' then
A = 1025
if TACANChannel < 64 then
A = 1088
end
else -- 'X'
if TACANChannel < 64 then
A = 962
end
end
return (A + TACANChannel - B) * 1000000
end
function Utils.getWindBearingAndVel(point)
local tPoint = Utils.makeVec3(point)
local gLevel = land.getHeight({x = tPoint.x, y = tPoint.z})
if tPoint.y <= gLevel then
tPoint.y = gLevel + 10
end
local t = atmosphere.getWind(tPoint)
local bearing = math.atan2(t.z, t.x)
local vel = math.sqrt(t.x^2 + t.z^2)
return bearing, vel
end
--- Returns an array containing a group's units positions.
-- e.g.
-- {
-- [1] = {x = 299435.224, y = -1146632.6773},
-- [2] = {x = 663324.6563, y = 322424.1112}
-- }
-- @tparam number|string groupIdent group id or name
-- @treturn table array containing positions of each group member
function Utils.getWayPoints(groupIdent)
-- search by groupId and allow groupId and groupName as inputs
local gpId = groupIdent
if type(groupIdent) == 'string' and not tonumber(groupIdent) then
local group = Group.getByName(groupIdent)
if not group then return end
gpId = group:getID()
end
for coa_name, coa_data in pairs(env.mission.coalition) do
if type(coa_data) == 'table' then
if coa_data.country then --there is a country table
for cntry_id, cntry_data in pairs(coa_data.country) do
for obj_cat_name, obj_cat_data in pairs(cntry_data) do
if obj_cat_name == "helicopter" or obj_cat_name == "ship" or obj_cat_name == "plane" or obj_cat_name == "vehicle" then -- only these types have points
if ((type(obj_cat_data) == 'table') and obj_cat_data.group and (type(obj_cat_data.group) == 'table') and (#obj_cat_data.group > 0)) then --there's a group!
for group_num, group_data in pairs(obj_cat_data.group) do
if group_data and group_data.groupId == gpId then -- this is the group we are looking for
if group_data.route and group_data.route.points and #group_data.route.points > 0 then
local points = {}
for point_num, point in pairs(group_data.route.points) do
if not point.point then
points[point_num] = { x = point.x, y = point.y }
else
points[point_num] = point.point --it's possible that the ME could move to the point = Vec2 notation.
end
end
return points
end
return
end --if group_data and group_data.name and group_data.name == 'groupname'
end --for group_num, group_data in pairs(obj_cat_data.group) do
end --if ((type(obj_cat_data) == 'table') and obj_cat_data.group and (type(obj_cat_data.group) == 'table') and (#obj_cat_data.group > 0)) then
end --if obj_cat_name == "helicopter" or obj_cat_name == "ship" or obj_cat_name == "plane" or obj_cat_name == "vehicle" or obj_cat_name == "static" then
end --for obj_cat_name, obj_cat_data in pairs(cntry_data) do
end --for cntry_id, cntry_data in pairs(coa_data.country) do
end --if coa_data.country then --there is a country table
end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then
end --for coa_name, coa_data in pairs(mission.coalition) do
end
function Utils.pointInPolygon(point, poly, maxalt)
point = Utils.makeVec3(point)
local px = point.x
local pz = point.z
local cn = 0
local newpoly = Utils.deepCopy(poly)
if not maxalt or (point.y <= maxalt) then
local polysize = #newpoly
newpoly[#newpoly + 1] = newpoly[1]
newpoly[1] = Utils.makeVec3(newpoly[1])
for k = 1, polysize do
newpoly[k+1] = Utils.makeVec3(newpoly[k+1])
if ((newpoly[k].z <= pz) and (newpoly[k+1].z > pz)) or ((newpoly[k].z > pz) and (newpoly[k+1].z <= pz)) then
local vt = (pz - newpoly[k].z) / (newpoly[k+1].z - newpoly[k].z)
if (px < newpoly[k].x + vt*(newpoly[k+1].x - newpoly[k].x)) then
cn = cn + 1
end
end
end
return cn%2 == 1
else
return false
end
end
function Utils.doString(s)
local f, err = loadstring(s)
if f then
return true, f()
else
return false, err
end
end
function Utils.drawPolygon(Coalition,MarkID,vecs,Color,FillColor,LineType,ReadOnly,Text)
local s=string.format("trigger.action.markupToAll(7, %d, %d,", Coalition, MarkID)
for _,vec in pairs(vecs) do
vec = Utils.makeVec3(vec)
--s=s..string.format("%s,", UTILS._OneLineSerialize(vec))
s=s..string.format("{x=%.1f, y=%.1f, z=%.1f},", vec.x, vec.y, vec.z)
end
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", Color[1], Color[2], Color[3], Color[4])
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", FillColor[1], FillColor[2], FillColor[3], FillColor[4])
s=s..string.format("%d,", LineType or 1)
s=s..string.format("%s", tostring(ReadOnly))
if Text and type(Text)=="string" and string.len(Text)>0 then
s=s..string.format(", \"%s\"", tostring(Text))
end
s=s..")"
-- Execute string command
local success=Utils.doString(s)
if not success then
self:E("ERROR: Could not draw polygon")
env.info(s)
end
end
end
File diff suppressed because it is too large Load Diff
+547
View File
@@ -0,0 +1,547 @@
--[[
函数:decimal_to_dms
功能:将十进制度坐标转换为度分秒格式(带方向标识)
参数:decimal (十进制度数值), is_latitude (是否为纬度)
返回:格式如 "N 41°28'46.44"" 的字符串
--]]
function decimal_to_dms(decimal, is_latitude)
local degrees = math.floor(math.abs(decimal))
local remainder = (math.abs(decimal) - degrees) * 60
local minutes = math.floor(remainder)
local seconds = (remainder - minutes) * 60
-- 确定方向标识
local direction
if is_latitude then
direction = (decimal >= 0) and "N" or "S"
else
direction = (decimal >= 0) and "E" or "W"
end
-- 格式化输出(秒保留两位小数)
return string.format("%s %d°%d'%.2f\"", direction, degrees, minutes, seconds)
end
-- -- 示例:纬度41.4795673 → N 41°28'46.44"
-- local lat = 41.4795673
-- local lon = -82.681172
-- print(decimal_to_dms(lat, true)) -- 输出:N 41°28'46.44"
-- print(decimal_to_dms(lon, false)) -- 输出:W 82°40'52.22"
--[[
函数:dms_to_decimal
功能:将度分秒格式(带方向标识)转换为十进制度
参数:dms_str (如 "N 41°28'46.44"")
返回:十进制度数值(南纬/西经为负数)
--]]
function dms_to_decimal(dms_str)
-- 提取方向、度、分、秒
local direction, degrees, minutes, seconds =
dms_str:match("([NSWE])%s*(%d+)°(%d+)'([%d%.]+)\"")
if not degrees then return nil, "Invalid format" end
degrees = tonumber(degrees)
minutes = tonumber(minutes)
seconds = tonumber(seconds)
-- 计算十进制度
local decimal = degrees + minutes/60 + seconds/3600
-- 处理方向符号
if direction == "S" or direction == "W" then
decimal = -decimal
end
return decimal
end
-- -- 示例:N 41°28'46.44" → 41.47957
-- local dms_lat = "N 41°28'46.44\""
-- local dms_lon = "W 82°40'52.22\""
-- print(dms_to_decimal(dms_lat)) -- 输出:41.47956666666667
-- print(dms_to_decimal(dms_lon)) -- 输出:-82.68117222222222
local airports = {
-- 埃及境内机场
{
name = "Cairo International Airport (HECA)",
lat = "N 30°07'18.84\"",
lon = "E 31°24'20.16\""
},
{
name = "Almaza Air Base (HEAZ)",
lat = "N 30°05'42.00\"",
lon = "E 31°22'03.00\""
},
{
name = "El Gora Air Base",
lat = "N 31°01'06.96\"",
lon = "E 34°14'06.00\""
},
{
name = "Sharm El Sheikh International Airport (HESH)",
lat = "N 27°58'37.92\"",
lon = "E 34°23'40.92\""
},
-- 以色列境内机场
{
name = "Ben Gurion Airport (LLBG)",
lat = "N 32°00'33.84\"",
lon = "E 34°52'57.72\""
},
{
name = "Ovda Air Base (LLOV)",
lat = "N 29°56'25.08\"",
lon = "E 34°56'08.88\""
},
{
name = "Hatzerim Air Base (LLHB)",
lat = "N 31°14'15.00\"",
lon = "E 34°39'00.00\""
},
{
name = "Nevatim Air Base (LLNV)",
lat = "N 31°12'30.00\"",
lon = "E 35°00'45.00\""
},
-- 约旦机场(待实装)
{
name = "Aqaba International Airport (OJAQ)",
lat = "N 29°36'41.76\"",
lon = "E 35°01'05.16\""
},
{
name = "King Hussein Air Base (OJMF)",
lat = "N 32°21'23.04\"",
lon = "E 36°15'33.12\""
}
}
local Mission_tencent_1 = {
{
lat = "N 29°45'00.00\"",
lon = "E 33°15'00.00\"",
name = 'Red Base & Red SA19',
},
{
lat = "N 29°48'00.00\"",
lon = "E 33°12'00.00\"",
name = 'Red container',
},
{
lat = "N 29°50'00.00\"",
lon = "E 33°10'00.00\"",
name = 'Red ammo',
},
{
lat = "N 29°47'00.00\"",
lon = "E 33°17'00.00\"",
name = 'Red armor',
},
{
lat = "N 29°49'00.00\"",
lon = "E 33°11'00.00\"",
name = 'Red generator',
},
{
lat = "N 29°46'00.00\"",
lon = "E 33°14'00.00\"",
name = 'Red SA9',
},
{
lat = "N 29°43'00.00\"",
lon = "E 33°20'00.00\"",
name = 'Red Mi24 Base',
},
-- {
-- lat = "N 29°45'00.00\"",
-- lon = "E 33°15'00.00\"",
-- name = 'Red SA19',
-- },
{
lat = "N 29°30'00.00\"",
lon = "E 33°00'00.00\"",
name = 'Blue Base',
},
{
lat = "N 29°40'00.00\"",
lon = "E 33°05'00.00\"",
name = 'Alpha',
},
{
lat = "N 29°42'00.00\"",
lon = "E 33°08'00.00\"",
name = 'Bravo',
},
{
lat = "N 29°44'00.00\"",
lon = "E 33°10'00.00\"",
name = 'Charlie',
},
-- {
-- lat = "N 29°48'00.00\"",
-- lon = "E 33°12'00.00\"",
-- name = 'Ch47 land',
-- },
}
local Mission_tencent_2 = {
-- 蓝方单位
{lat = "N30°5'35.67\"", lon = "E30°53'59.10\"", name = "Blue HQ (Cairo West Airbase)"},
{lat = "N30°33'00.00\"", lon = "E32°10'30.00\"", name = "Blue LZ_Alpha (Covert Insertion)"},
{lat = "N30°24'03.61\"", lon = "E33°09'22.33\"", name = "Blue CP1_Wadi al Jandali"},
{lat = "N30°19'43.40\"", lon = "E32°16'55.67\"", name = "Blue CP2_Fayed West Dunes"},
{lat = "N30°46'58.88\"", lon = "E32°02'16.08\"", name = "Blue CP3_As Salihiyah South"},
-- 红方单位
{lat = "N30°35'24.29\"", lon = "E32°14'48.06\"", name = "Red Main Base (Al Ismailiyah Prison Camp)"},
{lat = "N30°35'33.18\"", lon = "E32°14'41.25\"", name = "Red Detention Facility"},
{lat = "N30°35'07.44\"", lon = "E32°15'02.17\"", name = "Red Secret Container"},
{lat = "N30°33'15.00\"", lon = "E32°12'30.00\"", name = "Red ZU-23 Technical (Position 1)"},
{lat = "N30°37'45.00\"", lon = "E32°16'20.00\"", name = "Red Rocket Technical Group"},
{lat = "N30°35'50.00\"", lon = "E32°15'10.00\"", name = "Red T-55 Platoon"},
{lat = "N30°34'55.00\"", lon = "E32°13'40.00\"", name = "Red ZSU-23-4 Position"},
{lat = "N30°36'12.00\"", lon = "E32°14'50.00\"", name = "Red SA-18 Outpost"},
{lat = "N30°35'30.00\"", lon = "E32°14'55.00\"", name = "Red T-72 Guard Post"},
{lat = "N30°35'18.00\"", lon = "E32°14'32.00\"", name = "Red Pantsir-S1 Site"},
{lat = "N30°35'42.00\"", lon = "E32°14'15.00\"", name = "Red Arrow-1 SAM Bunker"},
{lat = "N30°36'50.12\"", lon = "E32°13'30.88\"", name = "Red Ammo Depot"},
{lat = "N30°34'55.67\"", lon = "E32°13'40.29\"", name = "Red Power Station"},
{lat = "N30°37'12.34\"", lon = "E32°16'45.67\"", name = "Red Armor Assembly Area"},
{lat = "N30°33'45.21\"", lon = "E32°12'15.78\"", name = "Red Mortar Position"},
{lat = "N30°34'13.50\"", lon = "E32°6'35.36\"", name = "Red Abu Suwayr Radar Site"},
-- 中立地形/目标
{lat = "N30°28'00.00\"", lon = "E32°18'30.00\"", name = "Neutral GPS Jamming Zone"},
{lat = "N31°11'13.63\"", lon = "E35°0'12.75\"", name = "Neutral Nevatim Airbase"},
{lat = "N30°46'24.05\"", lon = "E34°39'13.86\"", name = "Neutral Ramon Airbase"},
-- 环境参考点
-- {lat = "N30°33'00.00\"", lon = "E32°10'30.00\"", name = "Neutral Sandstorm Zone (11:00-14:00)"},
-- {lat = "N30°35'00.00\"", lon = "E32°15'00.00\"", name = "Neutral Prison Camp LZ"},
}
local Mission_tencent_3 = {
-- 蓝方相关
{ name = "Blue HQ", lat = "N 30°19'43.40\"", lon = "E 32°16'55.67\"" },
{ name = "Blue Fire Support", lat = "N 30°50'00.00\"", lon = "E 32°50'00.00\"" },
{ name = "Blue WP1 低空离场,规避雷达", lat = "N 30°20'12.00\"", lon = "E 32°18'00.00\"" },
{ name = "Blue WP2 扫描装甲集结地(雷达探测)", lat = "N 30°45'00.00\"", lon = "E 32°45'00.00\"" },
{ name = "Blue WP3 标记迫击炮阵地(光电侦察)", lat = "N 30°55'30.00\"", lon = "E 33°10'00.00\"" },
{ name = "Blue WP4 低空穿越峡谷,接近红方HQ", lat = "N 31°02'00.00\"", lon = "E 33°30'00.00\"" },
{ name = "Blue WP5 El Gora 红外扫描发电厂", lat = "N 31°04'15.23\"", lon = "E 34°08'15.61\"" },
-- 红方相关
{ name = "Red HQ", lat = "N 28°40'35.65\"", lon = "E 34°03'49.60\"" },
{ name = "Red Ammo Depot", lat = "N 28°42'00.00\"", lon = "E 34°06'00.00\"" },
{ name = "Red Power Plant", lat = "N 28°39'30.00\"", lon = "E 34°02'00.00\"" },
{ name = "Red Secret Container", lat = "N 28°40'55.00\"", lon = "E 34°04'05.00\"" },
{ name = "Red T-55", lat = "N 28°41'00.00\"", lon = "E 34°04'30.00\"" },
{ name = "Red SA-18", lat = "N 28°40'20.00\"", lon = "E 34°03'15.00\"" },
{ name = "Red SA-19", lat = "N 28°40'45.00\"", lon = "E 34°05'00.00\"" },
{ name = "Red lockup", lat = "N 28°40'50.00\"", lon = "E 34°04'10.00\"" },
{ name = "Red Armor Camp", lat = "N 30°45'00.00\"", lon = "E 32°45'00.00\"" },
{ name = "Red Mortar Site", lat = "N 30°55'30.00\"", lon = "E 33°10'00.00\"" }
}
local Mission_tencent_4 = {
-- 蓝方相关
{ name = "Blue HQ", lat = "N 31°08'15.00\"", lon = "E 33°48'22.00\"" },
{ name = "Blue WP1", lat = "N 31°10'00.00\"", lon = "E 33°50'00.00\"" },
{ name = "Blue WP2", lat = "N 30°55'30.00\"", lon = "E 34°15'00.00\"" },
{ name = "Blue WP3", lat = "N 29°20'00.00\"", lon = "E 34°25'00.00\"" },
{ name = "Blue WP4", lat = "N 28°45'00.00\"", lon = "E 34°00'00.00\"" },
{ name = "Blue Fire Support", lat = "N 30°50'00.00\"", lon = "E 34°10'00.00\"" },
{ name = "Blue Ch47 LZ", lat = "N 28°41'00.00\"", lon = "E 33°59'30.00\"" },
-- 红方相关
{ name = "Red HQ", lat = "N 28°42'30.00\"", lon = "E 33°58'45.00\"" },
{ name = "Red Ammo Depot", lat = "N 28°44'00.00\"", lon = "E 34°05'30.00\"" },
{ name = "Red Power Plant", lat = "N 28°40'00.00\"", lon = "E 33°55'00.00\"" },
{ name = "Red T-55", lat = "N 28°43'00.00\"", lon = "E 34°01'30.00\"" },
{ name = "Red SA19", lat = "N 28°42'45.00\"", lon = "E 34°00'15.00\"" },
-- 中立目标
{ name = "Neutral Armor Camp", lat = "N 30°55'30.00\"", lon = "E 34°15'00.00\"" },
{ name = "Neutral Wadi Feiran", lat = "N 29°20'00.00\"", lon = "E 34°25'00.00\"" },
}
local Mission_ds_1 = {
-- 蓝方相关
{ name = "Blue HQ", lat = "N 30°5'53.28\"", lon = "E 31°25'11.54\"" }, -- 开罗国际机场
{ name = "Blue Staging_Area", lat = "N 30°10'10.00\"", lon = "E 31°30'00.00\"" }, -- 集结点
-- 红方相关
{ name = "Red HQ", lat = "N 30°35'24.29\"", lon = "E 32°14'48.06\"" }, -- Al Ismailiyah机场
{ name = "Red AA_Site1", lat = "N 30°34'13.50\"", lon = "E 32°6'35.36\"" }, -- Abu Suwayr附近
{ name = "Red Tunguska", lat = "N 30°33'00.00\"", lon = "E 32°12'00.00\"" },
{ name = "Red Armor_Cluster", lat = "N 30°36'00.00\"", lon = "E 32°16'00.00\"" },
{ name = "Red Power_Plant", lat = "N 30°37'30.00\"", lon = "E 32°15'30.00\"" },
-- 中立参考点
{ name = "Neutral Recon_Area1", lat = "N 30°25'25.78\"", lon = "E 32°20'6.18\"" }, -- Difarsuwar机场
{ name = "Neutral LZ", lat = "N 30°38'00.00\"", lon = "E 32°13'00.00\"" },
{ name = "Neutral Waypoint1", lat = "N 29°58'00.00\"", lon = "E 31°12'00.00\"" }, -- 吉萨金字塔南侧
}
local Mission_ds_2 = {
{ name = "Blue HQ", lat = "N 30°35'24.29\"", lon = "E 32°14'48.06\"" },
{ name = "Neutral Pilot Crash Site", lat = "N 30°18'20.00\"", lon = "E 33°15'45.00\"" },
{ name = "Neutral Canyon", lat = "N 30°09'30.00\"", lon = "E 33°22'00.00\"" },
{ name = "Red Power Plant", lat = "N 30°13'50.00\"", lon = "E 33°28'30.00\"" },
{ name = "Red HQ", lat = "N 30°11'16.75\"", lon = "E 33°25'32.05\"" },
{ name = "Red ZSU-23", lat = "N 30°10'55.00\"", lon = "E 33°25'10.00\"" },
{ name = "Red ZSU-23", lat = "N 30°11'30.00\"", lon = "E 33°26'15.00\"" },
{ name = "Red SA18", lat = "N 30°11'05.00\"", lon = "E 33°25'45.00\"" },
{ name = "Red ZU-23", lat = "N 30°11'20.00\"", lon = "E 33°24'50.00\"" },
{ name = "Red Armor Assembly", lat = "N 30°12'00.00\"", lon = "E 33°27'00.00\"" },
{ name = "Red Secret Container", lat = "N 30°11'10.00\"", lon = "E 33°25'30.00\"" },
}
local Mission_ds_3 = {
{ name = "Blue HQ", lat = "N 30°45'00.00\"", lon = "E 32°30'00.00\"" },
{ name = "Blue WP1 Wadi al-Arish河谷", lat = "N 30°20'00.00\"", lon = "E 33°10'00.00\"" },
{ name = "Neutral Oasis", lat = "N 30°00'00.00\"", lon = "E 33°45'00.00\"" },
{ name = "Neutral Pilot Crash Site", lat = "N 29°58'00.00\"", lon = "E 33°40'00.00\"" },
{ name = "Neutral Canyon", lat = "N 29°48'00.00\"", lon = "E 33°52'00.00\"" },
{ name = "Red Power Plant", lat = "N 29°45'00.00\"", lon = "E 33°58'00.00\"" },
{ name = "Red HQ", lat = "N 29°50'00.00\"", lon = "E 33°55'00.00\"" },
{ name = "Red ZSU-23", lat = "N 29°49'45.00\"", lon = "E 33°54'15.00\"" },
{ name = "Red SA18", lat = "N 29°50'15.00\"", lon = "E 33°55'45.00\"" },
{ name = "Red ZU-23皮卡", lat = "N 30°11'20.00\"", lon = "E 33°24'50.00\"" },
{ name = "Red T-55", lat = "N 29°50'30.00\"", lon = "E 33°55'30.00\"" },
{ name = "Red Armor Assembly", lat = "N 29°50'00.00\"", lon = "E 33°55'00.00\"" },
{ name = "Red Secret Container", lat = "N 29°47'30.00\"", lon = "E 33°53'15.00\"" },
{ name = "Red Red SAM Site", lat = "N 29°55'00.00\"", lon = "E 33°50'00.00\"" },
}
local sinai_coordinates = {
{
name = "坎塔腊 (Qantarah)",
lat = 30.85000,
lon = 32.31667
},
{
name = "伊斯梅利亚 (Ismailia)",
lat = 30.58333,
lon = 32.26667
},
{
name = "德维斯瓦 (Deversoir)",
lat = 30.50000,
lon = 32.33333
},
{
name = "沙卢法 (Shallufa)",
lat = 29.91667,
lon = 32.50000
},
{
name = "西奈山 (Mount Sinai)",
lat = 28.53972,
lon = 33.97333
},
{
name = "赛德港 (Port Said)",
lat = 31.25000,
lon = 32.30000
},
{
name = "福阿德港 (Port Fuad)",
lat = 31.23333,
lon = 32.31667
},
{
name = "苏伊士城 (Suez City)",
lat = 29.96667,
lon = 32.55000
},
{
name = "戈兰高地核心区 (Golan Heights)",
lat = 33.00000,
lon = 35.75000
},
{
name = "阿里什 (Arish)",
lat = 31.13333,
lon = 33.80000
},
{
name = "沙姆沙伊赫 (Sharm El-Sheikh)",
lat = 27.85000,
lon = 34.26667
}
}
local plan_1 = {
{
name = "核心指挥所(西奈山制高点)",
lat = 28.53972,
lon = 33.97333 -- 西奈山主峰
},
{
name = "隐蔽补给站(东南山谷)",
lat = 28.51667,
lon = 34.00000 -- 西奈山东南5公里峡谷
},
{
name = "前哨观察点(沙姆沙伊赫北侧)",
lat = 27.95000,
lon = 34.30000 -- 控制蒂朗海峡公路
},
{
name = "机动部队集结点(阿里什南郊)",
lat = 31.10000,
lon = 33.78333 -- 沙漠公路交汇处
},
{
name = "应急撤离点(德维斯瓦旧机场)",
lat = 30.48333,
lon = 32.33333 -- 废弃军事设施
}
}
local plan_2 = {
{
name = "指挥中枢(西奈山北麓)",
lat = 28.60000,
lon = 33.95000 -- 山体反斜面
},
{
name = "公路控制站(苏伊士城东)",
lat = 29.96667,
lon = 32.60000 -- 8号公路咽喉
},
{
name = "直升机前哨(沙卢法高地)",
lat = 29.91667,
lon = 32.50000 -- 俯瞰运河区
},
{
name = "油料储备点(伊斯梅利亚东南)",
lat = 30.56667,
lon = 32.30000 -- 地下储油设施
},
{
name = "伏击区(坎塔腊沙漠路段)",
lat = 30.85000,
lon = 32.31667 -- 公路沙丘地带
}
}
local plan_3 = {
{
name = "主基地(西奈山南坡)",
lat = 28.50000,
lon = 33.98000 -- 洞穴密集区
},
{
name = "海岸观测站(沙姆沙伊赫西侧)",
lat = 27.85000,
lon = 34.20000 -- 控制红海航道
},
{
name = "沙漠机动中枢(阿里什-西奈山中间点)",
lat = 29.80000,
lon = 33.50000 -- 多条沙漠公路交汇
},
{
name = "防空预警点(戈兰高地南延)",
lat = 32.80000,
lon = 35.70000 -- 战略制高点
},
{
name = "应急港口(福阿德港东南)",
lat = 31.20000,
lon = 32.35000 -- 小型隐蔽码头
}
}
-- 注:经纬度转换规则示例:
-- N 30°45'00" = 30 + 45/60 + 0/3600 = 30.75000
-- E 33°25'00" = 33 + 25/60 + 0/3600 = 33.41667
local markIDCounter = 10
local function drawMarks(dmsTable)
for i,dms in ipairs(dmsTable) do
local newDecimal = {
lat = dms.lat,
lon = dms.lon,
}
if type(dms.lat) ~= 'number' or type(dms.lon) ~= 'number' then
newDecimal.lat = dms_to_decimal(dms.lat)
newDecimal.lon = dms_to_decimal(dms.lon)
end
local newPoint = coord.LLtoLO(newDecimal.lat,newDecimal.lon)
local newMarkID = markIDCounter
markIDCounter = markIDCounter + 1
local drawColor = {
ring = {0,0,1,1},
fill = {0,0,1,0.5},
}
if string.match(dms.name, "^Red%f[%s]") == 'Red' then
drawColor = {
ring = {1,0,0,1},
fill = {1,0,0,0.5},
}
end
if string.match(dms.name, "^Neutral%f[%s]") == 'Neutral' then
drawColor = {
ring = {1,1,1,1},
fill = {0,1,1,0.5},
}
end
trigger.action.circleToAll(-1,newMarkID,newPoint,500,drawColor.ring,drawColor.fill,1)
local textPoint = newPoint
textPoint.x = textPoint.x + 500
local textId = markIDCounter
markIDCounter = markIDCounter + 1
trigger.action.textToAll(-1,textId,textPoint,drawColor.ring,{1,1,0,0.3},12,false,dms.name)
end
end
drawMarks(plan_3)
Utils.Debug("new")
-- local airbase_Sinal_Dms = {}
-- local airbase_Sinal = world.getAirbases()
-- for i, airbase in ipairs(airbase_Sinal) do
-- local airbasePoint = airbase:getPoint()
-- local lat,lon,alt = coord.LOtoLL(airbasePoint)
-- local airbase_Latlong = {
-- lat = decimal_to_dms(lat,true),
-- lon = decimal_to_dms(lon,false),
-- name = airbase:getName(),
-- }
-- table.insert(airbase_Sinal_Dms,airbase_Latlong)
-- local newMarkID = markIDCounter
-- markIDCounter = markIDCounter + 1
-- trigger.action.circleToAll(-1,newMarkID,airbasePoint,500,{1,0,0,1},{1,0,0,0.5},1)
-- local textPoint = airbasePoint
-- textPoint.x = textPoint.x + 500
-- local textId = markIDCounter
-- markIDCounter = markIDCounter + 1
-- trigger.action.textToAll(-1,textId,textPoint,{1,0,0,1},{1,1,0,0.3},12,false,airbase_Latlong.name)
-- end
-- local logText = 'airbase_Sinal_Dms:\n'
-- for i,airbase_dms in ipairs(airbase_Sinal_Dms) do
-- logText = logText..'Airbase: '..airbase_dms.name..' lat: '..airbase_dms.lat..' lon: '..airbase_dms.lon..'\n'
-- end
-- env.info(logText)