print('---start---'); local OrelsNotAllDead = false; for i=1,8 do if ScenEdit_GetUnit({Side='Russian Federation', Name="Orel #"..i,}) ~= nil then --this code will only execute if there is no error. print('Orel ' .. i .. ' still exists'); OrelsNotAllDead = true -- it only takes one to exist to set the flag. end end print('Orels_status: ' .. tostring(OrelsNotAllDead)); if OrelsNotAllDead == false then local myMission = ScenEdit_GetMission ('Russian Federation', 'Borey II Nuclear Strike on Chitose AB') local bUnitAlreadyAssigned = false; local myUnit = ScenEdit_GetUnit({Side='Russian Federation', Name='PLARB-955A Borey II',}) if myUnit ~= nil then -- verify Borey II SSBN exists local myNukeSubGuid = myUnit.guid; --store this to compare if myMission then -- is true when mission exists\getmission() returend non-nil for k,v in ipairs(myMission.unitlist) do if(v == myNukeSubGuid) then bUnitAlreadyAssigned = true end end end if bUnitAlreadyAssigned == false then --only assign it if it's not already there --keep in mind unless you at the end of this disable the event from running it will keep running every 30 seconds. --so let's not keep 'reassigning' it's mission and possibly resetting what the unit was up to if it was engaged etc. print('SSBN is still active and not yet assigned.'); ScenEdit_SetDoctrine({side="Russian Federation", name="PLARB-955A Borey II"}, {use_nuclear_weapons= "yes" }); ScenEdit_AssignUnitToMission('PLARB-955A Borey II', 'Borey II Nuclear Strike on Chitose AB'); else print('Unit is already assigned to mission.'); end ScenEdit_SetMission('Russian Federation', 'Borey II Nuclear Strike on Chitose AB', {isactive=true}); print('unit is assigned to mission, nuke wpncon set, and mission marked active.'); ScenEdit_SetEvent('Check if to Assign Borey II SSBN to Chitose AB Nuclear Strike',{isActive=false,IsRepeatable=false}); print('Orel strike force checking event now set to inactive.'); else print('Sub PLARB-955A Borey II already destroyed or not found, could not add to mission.'); ScenEdit_SetEvent('Check if to Assign Borey II SSBN to Chitose AB Nuclear Strike',{isActive=false,IsRepeatable=false}); print('Orel strike force checking event now set to inactive.'); end end print("--end--")