You can spawn in things (and out) rather than create all.thewood1 wrote: Tue Jul 22, 2025 5:08 pm 1) It has zero impact on the scenario. There are thousands of whales and larger ocean life that aren't represented as well. I have not heard any mention of tha in the thread.
2) Feel free to show us a scenario completed to your liking to demonstrate.
3) We can see how the performance of the scenario compares to an unaltered one.
--Adds a contact with ASuW mission on bearing with specified ship. Center ship is the unit you want to target.
-- Check if the Blue side's CVN unit exists
if ScenEdit_GetUnit({side='Blue', unitname='Boxer'}) ~= nil then
-- Adding Unit at random position 40-80 miles away
local TargetedUnit = ScenEdit_GetUnit({unitname="Boxer", side='Blue'})
-- Submarine types: Pakistani DJ Khalid, Pakistani S26, China XLUUV, Russia Akula 2
--local SubID = {720, 738, 733, 748}
local SubID = {187, 189, 58, 454}
-- Initialize variables
--Within 1-2 CZs
local ranRange = math.random(40, 80)
--Want a sub within 180 degrees of the bearing the target ship is traveling. Get min and max angle in variables and use as the random bearing.
local subMinAngle = TargetedUnit.heading - ranRange / 2
local subMaxAngle = TargetedUnit.heading + ranRange / 2
local subBearing = math.random(subMinAngle,subMaxAngle)
--local subBearing = math.random(0, 359)
local subranPos = {}
local randSubID = math.random(1, 4)
-- Repeat until a suitable underwater position is found
repeat
ranRange = math.random(30, 70)
subBearing = math.random(subMinAngle,subMaxAngle)
--subBearing = math.random(0, 359)
subranPos = World_GetPointFromBearing({lat=TargetedUnit.latitude, lon=TargetedUnit.longitude, distance=ranRange, bearing=subBearing})
until World_GetElevation({lat=subranPos.latitude, lon=subranPos.longitude}) < -50 ---this is where you set minimum depth of water you want to add the unit
-- Generate a unique name for the submarine
local subName = 'Sub-' .. math.random(1000, 100000)
--set chance of contact type
local contactsuborfcontact= math.random(1,6)
if contactsuborfcontact ==1 then
-- Add the submarine unit to the Red side
ScenEdit_AddUnit({
type='Submarine',
name=subName,
DBID=SubID[randSubID],
heading=subBearing,
side='Red',
lat=subranPos.latitude,
lon=subranPos.longitude,
autodetectable=false
})
-- Add Reference Points for Mission
-- Reference points will be centered on the unit
local CenterUnit = ScenEdit_GetUnit({unitname="Boxer", side='Blue'})
local subrpbearingNE = 45
local subrpbearingNW = 315
local subrpbearingSE = 135
local subrpbearingSW = 225
local subrprange = 80 -- range from reference point to CenterUnit
local subrpNE = World_GetPointFromBearing({lat=CenterUnit.latitude, lon=CenterUnit.longitude, distance=subrprange, bearing=subrpbearingNE})
local subrpNW = World_GetPointFromBearing({lat=CenterUnit.latitude, lon=CenterUnit.longitude, distance=subrprange, bearing=subrpbearingNW})
local subrpSE = World_GetPointFromBearing({lat=CenterUnit.latitude, lon=CenterUnit.longitude, distance=subrprange, bearing=subrpbearingSE})
local subrpSW = World_GetPointFromBearing({lat=CenterUnit.latitude, lon=CenterUnit.longitude, distance=subrprange, bearing=subrpbearingSW})
-- Unique Reference Point Names
local rpsubName1 = 'RP-SUB-' .. math.random(1000, 100000)
local rpsubName2 = 'RP-SUB-' .. math.random(1000, 100000)
local rpsubName3 = 'RP-SUB-' .. math.random(1000, 100000)
local rpsubName4 = 'RP-SUB-' .. math.random(1000, 100000)
-- Add reference points in
ScenEdit_AddReferencePoint({side="Red", name=rpsubName1, lat=subrpNE.latitude, lon=subrpNE.longitude, highlighted=true})
ScenEdit_AddReferencePoint({side="Red", name=rpsubName4, lat=subrpSW.latitude, lon=subrpSW.longitude, highlighted=true})
ScenEdit_AddReferencePoint({side="Red", name=rpsubName2, lat=subrpNW.latitude, lon=subrpNW.longitude, highlighted=true})
ScenEdit_AddReferencePoint({side="Red", name=rpsubName3, lat=subrpSE.latitude, lon=subrpSE.longitude, highlighted=true})
--Add Mission
local rpsubmissionname = 'RP-SUB-MISSION-' .. math.random(1000, 100000)
local rpsubmissionReferencePoints={rpsubName1, rpsubName3,rpsubName4,rpsubName2}
local rpsubmission = ScenEdit_AddMission ('Red', rpsubmissionname, 'Patrol', {type='naval',zone= rpsubmissionReferencePoints} )
--Update Mission
ScenEdit_SetMission('Red',rpsubmissionname, {CheckOPA=false,ProsecutionZone=rpsubmissionReferencePoints,TransitDepthSubmarine="-200", StationDepthSubmarine='-25'})
ScenEdit_SetEMCON('Mission',rpsubmissionname,'Radar=Passive')
--add sub to mission
ScenEdit_AssignUnitToMission( subName, rpsubmissionname )
else if contactsuborfcontact >=2 then
ScenEdit_AddUnit({
type='Submarine',
name=subName,
DBID=94,--False Contact
heading=subBearing,
side='Nature',
altitude = '-200',
lat=subranPos.latitude,
lon=subranPos.longitude,
autodetectable=false
})
ScenEdit_SetUnit({name=subName, side='Nature', moveTo=false, manualaltitude='-75'})
else
end
end
else
-- Handle the case where the CVN unit doesn't exist (e.g., log an error, perform alternative actions)
print("Unit does not exist on the Blue side.")
end