diff --git a/Just_A_Training_Map.miz b/Just_A_Training_Map.miz index 5ce0fa1..c1b039f 100644 Binary files a/Just_A_Training_Map.miz and b/Just_A_Training_Map.miz differ diff --git a/Scripts/AARTanker.lua b/Scripts/AARTanker.lua new file mode 100644 index 0000000..129f4ac --- /dev/null +++ b/Scripts/AARTanker.lua @@ -0,0 +1,138 @@ +AARTanker = { + AllTankers = {}, + SpawnPoint_vec2 = {x=-246874,y=562226}, + + DefaultSettings = { + ['KC135_Low'] = { + Type = 'KC-135', + + Callsign_Name = 1, + Callsign_Number = 1, + + Radio = 335000000, + + TACAN = 35, + TACAN_Mode = 'X', + + Alt = 10000/3.28, + Speed = 250/1.944, + }, + + ['KC135_High'] = { + Type = 'KC-135', + + Callsign_Name = 1, + Callsign_Number = 2, + + Radio = 336000000, + + TACAN = 36, + TACAN_Mode = 'X', + + Alt = 16000/3.28, + Speed = 340/1.944, + }, + + ['KC135MPRS'] = { + Type = 'KC-135', + + Callsign_Name = 2, + Callsign_Number = 1, + + Radio = 337000000, + + TACAN = 37, + TACAN_Mode = 'X', + + Alt = 14000/3.28, + Speed = 340/1.944, + }, + + ['KC130'] = { + Type = 'KC-135', + + Callsign_Name = 2, + Callsign_Number = 2, + + Radio = 330000000, + + TACAN = 36, + TACAN_Mode = 'X', + + Alt = 11000/3.28, + Speed = 350/1.944, + }, + + } +} + +do + + function AARTanker:New(groupName,missionType) + if not groupName then return end + if type(groupName) ~= 'string' then return end + if not missionType then return end + + local obj = {} + obj.groupName = groupName + obj.group = Group.getByName(groupName) or AARTanker.Spawn(groupName,missionType) + obj.missionType = missionType + + obj.TACAN = nil + obj.TACAN_Mode = nil + obj.TACAN_On = false + + obj.Radio = nil + + + + + return obj + end + + function AARTanker.Spawn(groupName,missionType) + if not groupName then return end + if type(groupName) ~= 'string' then return end + if not missionType then return end + + local spawnData = {} + spawnData.name = groupName + spawnData.task = 'Refueling' + spawnData.modulation = radio.modulation.AM + spawnData.frequency = AARTanker.DefaultSettings[missionType].Radio + spawnData.units = { + [1] ={ + name = groupName..'-1', + type = AARTanker.DefaultSettings[missionType].Type, + skill = AI.Skill.EXCELLENT, + x = 1, + y = 1, + } + } + spawnData.route = AARTanker.getDefaultRoute(missionType) + + local newGroup = coalition.addGroup(country.id.CJTF_BLUE, Group.Category.AIRPLANE, spawnData) + if not newGroup:getName() then return end + + return newGroup + end + + function AARTanker.getDefaultRoute(missionType) + local route = {} + route.points = { + [1] = { + ['type'] = 'Turning Point', + ['action'] = 'Turning Point', + ['alt'] = AARTanker.DefaultSettings[missionType].Alt, + ['alt_type'] = 'BARO', + ['x'] = 1, + ['y'] = 1, + ['speed'] = AARTanker.DefaultSettings[missionType].Speed, + ['task'] = {} + }, + } + + end + + +end \ No newline at end of file diff --git a/Scripts/Buta's_Airboss.lua b/Scripts/Buta's_Airboss.lua index 63fddd6..6bb8e50 100644 --- a/Scripts/Buta's_Airboss.lua +++ b/Scripts/Buta's_Airboss.lua @@ -3,6 +3,8 @@ BAirboss = { Morse = nil, + ATC = nil, + TACAN = nil, TACAN_Mode = nil, TACAN_ON = false, @@ -56,6 +58,8 @@ do [BAirboss.CarrierType.FORRESTAL] = { Morse = 'FRS', + ATC = 269000000, + MarshalRadio = nil, LSORadio = nil, @@ -75,6 +79,8 @@ do [BAirboss.CarrierType.ROOSEVELT] = { Morse = 'RSV', + ATC = 261000000, + MarshalRadio = nil, LSORadio = nil, @@ -94,6 +100,8 @@ do [BAirboss.CarrierType.STENNIS] = { Morse = 'STN', + ATC = 264000000, + MarshalRadio = nil, LSORadio = nil, @@ -137,23 +145,11 @@ do self:setICLS() self:setLink4() self:setACLS(true) + self:setATC() return self end - function BAirboss: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 - function BAirboss.findClearPath(from,heading,range) local dest = Utils.vecTranslate(from,heading,range) @@ -196,10 +192,10 @@ do return onBoard_num_hundred + onBoard_num_tens + onBoard_num_ones end - function BAirboss:turnIntoWind() + function BAirboss:turnIntoWind(Delay) --Get weather data. local CarrierPoint = self.carrierUnit:getPoint() - local windBearing, windSpeed = self:getWindBearingAndVel(CarrierPoint) -- radians & m/s + local windBearing, windSpeed = Utils.getWindBearingAndVel(CarrierPoint) -- radians & m/s local magnetic = 7 @@ -295,9 +291,10 @@ do local Controller = self.carrierUnit:getGroup():getController() if not Controller then return self end + Delay = Delay or 1 timer.scheduleFunction(function (Mission) Controller:setTask(Mission) - end,Mission,timer.getTime()+1) + end,Mission,timer.getTime()+Delay) return self end @@ -307,13 +304,25 @@ do return self end - function BAirboss:setATCChannel(frequency,modulation,power) + function BAirboss:setATC(frequency,modulation,power) + frequency = frequency or BAirboss.DefaultSettings[self.carrierUnit:getTypeName()].ATC + if frequency < 1000000 then + frequency = frequency * 1000000 + + if frequency < 200000000 then + frequency = BAirboss.DefaultSettings[self.carrierUnit:getTypeName()].ATC + end + end + + power = power or 1 + modulation = modulation or radio.modulation.AM + local SetFrequency = { id = 'SetFrequencyForUnit', params = { frequency = frequency, - modulation = radio.modulation, - power = number, + modulation = modulation, + power = power, unitId = self.carrierUnit:getID(), } } @@ -323,7 +332,9 @@ do return self end - Controller:setCommand(ActivateBeacon) + Controller:setCommand(SetFrequency) + + return self end function BAirboss:setTACAN(Channel,Mode,MorseCode) @@ -435,6 +446,9 @@ end local Airboss_Roosevelt = BAirboss:New('USS Theodore Roosevelt') - Airboss_Roosevelt:turnIntoWind() + +local Airboss_Sten = BAirboss:New('John C. Stennis') +Airboss_Sten:turnIntoWind() + trigger.action.outText('Start',20) \ No newline at end of file diff --git a/Scripts/Utils.lua b/Scripts/Utils.lua index d741be0..d462ecc 100644 --- a/Scripts/Utils.lua +++ b/Scripts/Utils.lua @@ -171,6 +171,18 @@ do 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