Jump to content

Landing/Refueling in Mission Builder Issue


lharv71

Recommended Posts

Good Day!

 

I have designed a mission where I have two tankers trading off in orbit; therefore I setup that once they complete their time on station they land and refuel, then go to the last waypoint where I have them switch to the first waypoint.

I want the time of Landing/Refueling to be 90 min.

 

However this is not working? I would appreciate any assistance.........

 

Cheers

 

Capture.PNG


Edited by lharv71
Link to comment
Share on other sites

I seem to have better luck by keeping their time on station to around 2.5 hours.  If I let them go to bingo it doesn't seem to work.  I've never tried a 90 minute refuel time tho. I set my wpts as follows, tanker orbits between wp1 and 2 for 2.5 hours and lands at wp 3. It refuels and then I have it fly to a new wp 4, near wp 1 at the same altitude you want at wp 1.  At wp 4 I give it a command to switch to wp 1.  Been having pretty good luck with this. But it doesn't seem to be 100%. 

 

Another way I got around this was by making a trigger zone at the end of the runway on which your tanker/ AWACS is going to land.  You can trigger another to take off this way when your tanker lands.  You could also trigger another one by setting a trigger for your tanker that spawns a new one when the first is below a certain altitude.  The first would need to be an airstart above this altitude.

 

Hope this helps.  Good luck.

Link to comment
Share on other sites

AI landed at an airbase will automatically despawn after 30 minutes or so. Even with the land re fuel waypoint type. Depending on your needs it is arguably better to just respawn a group because relying on AI landing on bingo is possible to end up with the AI being killed.

 

I wrote a little script to just make sure a tanker is airborne most of the time. Its pretty simplistic because it groups it by tanker unit type and not anything else. Basically place your two tankers, set both to ramp starts, and uncontrolled. The script will select one at random to take-off, when that tanker reaches 10% fuel remaining the script will order it to fly to WP4, breaking its orbit. At the same time the script looks to see if any other tanker is available and will start one. When the original tanker lands and parks it'll respawn and will wait until it is its turn again. 

 

 

local tankers = {}
local tankersByType = {}

for name, data in pairs(mist.DBs.groupsByName) do
    if data.task == 'Refueling' then
        tankers[name] = {groupName = name, status = 'parked', type = data.units[1].type}
        if not tankersByType[data.units[1].type] then 
            tankersByType[data.units[1].type] = {}
        end
       table.insert(tankersByType[data.units[1].type], name)
    end
 end
local function groupIsDead(groupName) -- a certain bug hasn't been fixed, so I have to use this instead. 
    if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then
        return true
    end
    return false
end

 local function check()
    local activeTypes = {}
    for i, tanker in pairs(tankers) do -- tanker status stuff
        local gp = Group.getByName(tanker.groupName)
        if groupIsDead(tanker.groupName) == true or Group.getByName(tanker.groupName):getUnit(1):getFuel() == 0 then
            if tanker.status == 'landing' or tanker.status == 'route' then -- respawn group once it lands and parks and resources "gathers" it. 
                mist.respawnGroup(tanker.groupName, true)
                tanker.status = 'respawned'
            end
        else
            local tUnit = gp:getUnit(1)
            if tUnit:inAir() == true and tanker.status == 'takeoff' then
                tanker.status = 'route'
            elseif tUnit:inAir() == true and tUnit:getFuel() < 0.10 then -- rtb, tell other tanker to take off
                local con = gp:getController()
                if con then -- pop task ?
                    --env.info('pop task')
                    con:popTask()
                    con:setCommand({id = 'SwitchWaypoint', params = {fromWaypointIndex = 3, goToWaypointIndex = 4,}})
                    tanker.status = 'landing'

                end
            elseif tanker.status == 'respawed' and groupIsDead(tanker.groupName) == false then
                --env.info('changed to park')
                tanker.status = 'parked'
            end
            if tanker.status == 'route' or tanker.status == 'takeoff' then
                activeTypes[tUnit:getTypeName()] = true
            end
        end
    end

    for name, tanker in pairs(tankers) do -- iterate tankers
        if not activeTypes[tanker.type] then -- if type not active 
            if tanker.status == 'parked' then
                local found = name
                if tanker.status == 'respawned' then
                    local route = mist.getGroupRoute(tanker.groupName, true)
                    route[1].alt = land.getHeight(route[1].x,route[1].y) + 1000
                    route[1].airdromeId = nil
                    route[1].type = "Turning Point"
                    route[1].action = 'Fly Over Point'
                    mist.teleportToPoint({gpName = tanker.groupName, action = 'respawn', route = route})
                else
                    Group.getByName(tankers[found].groupName):getController():setCommand({id = 'Start', params = {}})
                    tankers[found].status = 'takeoff'
                end
                activeTypes[tanker.type] = true
            end
            
        end
    end
 end
 
for type, data in pairs(tankersByType) do -- start tankers
    
    local trnd = math.random(#data)
    Group.getByName(data[trnd]):getController():setCommand({id = 'Start', params = {}})
    tankers[data[trnd]].status = 'takeoff'
end
 
 mist.scheduleFunction(check, {}, timer.getTime() + 2, 60)
 

 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...