To be used with the above functions, I wrote this code which sets the firing time for Time Triggers. I'd run this at scenario load in order to ensures that the right number of TBM/GLCMs get fired at the right time:
I could probably modify the code to use for ALCMs/SLCMs but I'd have to take into account the position of the launch platform somehow since they move. If I did it that way, then I could have them fly or sail out to their launch baskets and fire at a specific time for coordination purposes. I need to think about that one more. I also included a "rolex" variable to add an arbitrary time offset to the whole war. I don't use it at this point, but someday I might.
-- scenario timing constants
oneMinute = 60
fiveMinutes = 5 * oneMinute
fifteenMinutes = 15 * oneMinute
oneHour = 60*oneMinute
threeHours = 3 * oneHour
sixHours = 6 * oneHour
oneDay = 24*oneHour
-- randomizes time on target so that I don't know exactly when the raid will come
mainStrikeMedianTimeOnTarget = os.time{ year=2020, month=6, day=21, hour=14, min= 00, sec=0 }
rolex = 0
-- the +/- three hours ensures the strike will occur within a 6 hour launch window. It could be whatever you want.
mainStrikeTimeOnTarget = mainStrikeMedianTimeOnTarget + math.random( (-1*threeHours) , threeHours ) + rolex
-- typically I'll put this code in a separate LUA action, just for modularity, but there's no reason it can't
-- be in the same as the above code it just depends on how you roll.
-- SEAD dedicated strikes will arrive on target five minutes prior to the main strike (480 kts * 5 min = 40 Nmi)
local seadTimeOnTarget = mainStrikeTimeOnTarget - fiveMinutes
-- andersenAFB is just the guid of the target for that portion of the raid, it could be anywhere. I just used
-- andersen because I developed the code for a Guam raid scenario. Change as it suits your purposes.
-- Similarly, "firstBnFirstBgd," "secondBnFirstBgd," etc. are set to guids of TBM battalions
local distanceFromFirstBnFirstBgdToAndersen = Tool_Range( firstBnFirstBgd , andersenAFB)
local distanceFromFirstBnSecondBgdToAndersen = Tool_Range( firstBnSecondBgd , andersenAFB)
local distanceFromSecondBnFirstBgdToAndersen = Tool_Range( secondBnFirstBgd , andersenAFB)
local distanceFromSecondBnSecondBgdToAndersen = Tool_Range( secondBnSecondBgd , andersenAFB)
local missileSpeed = 7500
local missileFirstBnFirstBgdFlyoutTime = (distanceFromFirstBnFirstBgdToAndersen / missileSpeed ) * oneHour
local missileFirstBnSecondBgdFlyoutTime = (distanceFromFirstBnSecondBgdToAndersen / missileSpeed) * oneHour
local missileSecondBnFirstBgdFlyoutTime = ( distanceFromSecondBnFirstBgdToAndersen / missileSpeed ) * oneHour
local missileSecondBnSecondBgdFlyoutTime = ( distanceFromSecondBnSecondBgdToAndersen / missileSpeed) * oneHour
local tbmFirstBnFirstBgdSeadMissionStartTime = seadTimeOnTarget - missileFirstBnFirstBgdFlyoutTime
local tbmFirstBnSecondBgdSeadMissionStartTime = seadTimeOnTarget - missileFirstBnSecondBgdFlyoutTime
local tbmSecondBnFirstBgdMainStrikeMissionStartTime = mainStrikeTimeOnTarget - missileSecondBnFirstBgdFlyoutTime
local tbmSecondBnSecondBgdMainStrikeMissionStartTime = mainStrikeTimeOnTarget - missileSecondBnSecondBgdFlyoutTime
local tbmFirstBnFirstBgdSEADMissionTrigger = ScenEdit_GetEvent('Launch Northern TBM SEAD Raid', 2)
local tbmFirstBnSecondBgdSEADMissionTrigger = ScenEdit_GetEvent('Time For Southern TBM Raid - SEAD Wave', 2)
local tbmFirstBnFirstBgdSEADMissionEvent = ScenEdit_GetEvent('Launch Southern TBM SEAD Raid', 1)
local tbmFirstBnSecondBgdSEADMissionEvent = ScenEdit_GetEvent('Launch Northern TBM SEAD Raid', 1)
local tbmSecondBnFirstBgdMainMissionEvent = ScenEdit_GetEvent('Launch Southern TBM Main Raid', 1)
local tbmSecondBnSecondBgdMainMissionEvent = ScenEdit_GetEvent('Launch Northern TBM Main Raid', 1)
local tbmFirstBnFirstBgdSEADMissionTriggerID = tbmFirstBnFirstBgdSEADMissionEvent.details.triggers[1].Time.ID
local tbmFirstBnSecondBgdSEADMissionTriggerID = tbmFirstBnSecondBgdSEADMissionEvent.details.triggers[1].Time.ID
local tbmSecondBnFirstBgdMainMissionTriggerID = tbmSecondBnFirstBgdMainMissionEvent.details.triggers[1].Time.ID
local tbmSecondBnSecondBgdMainMissionTriggerID = tbmSecondBnSecondBgdMainMissionEvent.details.triggers[1].Time.ID
ScenEdit_SetTrigger( {Description=tbmFirstBnFirstBgdSEADMissionTriggerID, Time=os.date('%m/%d/%Y %I:%M:%S %p', tbmFirstBnFirstBgdSeadMissionStartTime ) } )
ScenEdit_SetTrigger( {Description=tbmFirstBnSecondBgdSEADMissionTriggerID , Time=os.date('%m/%d/%Y %I:%M:%S %p', tbmFirstBnSecondBgdSeadMissionStartTime ) } )
ScenEdit_SetTrigger( {Description=tbmSecondBnFirstBgdMainMissionTriggerID , Time=os.date('%m/%d/%Y %I:%M:%S %p', tbmSecondBnFirstBgdMainStrikeMissionStartTime ) } )
ScenEdit_SetTrigger( {Description= tbmSecondBnSecondBgdMainMissionTriggerID , Time=os.date('%m/%d/%Y %I:%M:%S %p', tbmSecondBnSecondBgdMainStrikeMissionStartTime ) } )
Not sure this is displayed correctly.