Jump to content

shnicklefritz

Members
  • Posts

    35
  • Joined

  • Last visited

  1. Thanks, I just thought there might be a place as at the end of the mission in the debriefing you can sift through the different events, sorting by event, initiator, coalition, etc. I just didn't want to create an event handler and have a massive table if there was a more efficient way of going back through and adding it retrospectively.
  2. If I'm not mistaken, when you assign a tanker the task on the menu bar, on the right hand side of the mission editor, it will have the tanker task through all of its waypoints. As a result, it will respond to rejoin requests at anytime during the flight, regardless of where it is on its flight path. This is subject to the exception that if RTB on bingo is set true (or checked), it will go straight home and won't respond to anything. If you delete that task (the one that is in all waypoints) and instead add the tanker task say, for example, at waypoint 5 and ends at waypoint 8, it will only respond to rejoin requests after it reaches 5 and will cease after reaching 8. Also, if you have orbit at 7, it will orbit at 7, to the waypoint 8 point, but will not trigger waypoint 8. This is my experience, and someone may have other information / experience that may be along shortly. Hope this helps.
  3. It's a feature in CTLD. You would need to setup the zones that you want where troops/diplomats/whatever are going to be picked up, these are under the ctld.pickupZones table. Just look at the instructions in CTLD for pickup zones. You can set a limit on the zones. But when in a pickupzone, you will be allowed to pickup all of the types of troops from the ctld.loadableGroups table. So you will want to make sure your loadable groups are named and limited appropriately. After you have the CTLD settings you like, you need to create the extract zones. These are the zones where you return troops/diplomats/whatever. To create these, paste these in DO SCRIPT action with a condition of time more, 1 or more seconds to allow the main CTLD file to upload. Paste the following for every extract zone you want to create, also make sure you have these zones created in the mission editor with the names matching exactly: mind the caps, lua is case sensitive. ctld.createExtractZone(_zone, _flagNumber, _smoke) For example, ctld.createExtractZone(MyZone, 100, 0) will create a extract zone at the location in the mission editor called "MyZone." Every time troops are dropped in the zone, flag 100 will increase by the number of troops dropped, i.e., if there are 10 troops in your loadableGroups, Flag 100 will equal 10 on the first drop and increment by 10; 0 would mean green smoke. Then in a separate mission editor trigger, have a trigger that when FLAG EQUALS, 100 and whatever value you want, then whatever ACTION you want.
  4. Can anyone tell me if there is a way to sift through events after they happen, rather than on event with an event handler?
  5. Paste this code in ONCE trigger, No Conditions, ACTION DO SCRIPT; then change the names in the "EWR_GroupNames" table to the group names you have in the mission editor. Also, set the "activeScanTime to the number of seconds each EWR will scan. It doesn't necessarily account for randomization of the EWR group if one dies, nor does it account for more than three EWRs, though these two issues can be changed; however, it does what you ask. EWR_GroupNames = { --exact Group names from the mission editor, include #001 if applicable. "GroupNameFromMissionEditor", "GroupNameFromMissionEditor2", "GroupNameFromMissionEditor3", } activeScanTime = 300 --seconds, how long each EWR will scan for i=1, #EWR_GroupNames do --this turns the EWRs off, initially. local group = Group.getByName(EWR_GroupNames[i]) if group ~= nil and group:isExist() then group:getController():setOnOff(false) end end activeScanner = {} --keeps track of active scanner function ewrScanner() local r = nil local activeGroup = nil if #activeScanner == 0 or activeScanner == nil then r = math.random(1, 3) else r = math.random(1, 2) activeGroup = Group.getByName(activeScanner[1]) if activeGroup ~= nil and activeGroup:isExist() then activeGroup:getController():setOnOff(false) table.remove(activeScanner, 1) table.insert(EWR_GroupNames, activeGroup:getName()) end end local newScanner = Group.getByName(EWR_GroupNames[r]) if newScanner ~= nil and newScanner:isExist() then newScanner:getController():setOnOff(true) table.insert(activeScanner, newScanner:getName()) table.remove(EWR_GroupNames, r) end timer.scheduleFunction(ewrScanner, nil, timer.getTime() + activeScanTime) end ewrScanner()
  6. There is no way to reference which specific unit triggered your condition in a zone based on current mission editor triggers. There is a way to reference or iterate, rather, through each group, then each groups units’ positions to see if any one of them is in the zone. I personally am unaware of any other way. This is why MiST exist. In fact, MiST has a function that does exactly what you describe. https://wiki.hoggitworld.com/view/Mission_Scripting_Tools_Documentation function unitsInZone() local allBlueAircraft = coalition.getGroups(2, 0) -- (1=RED 2=BLUE, 0==AIRCRAFT) local zone = trigger.misc.getZone("myMissionEditorZoneName") for i, group in pairs(allBlueAircraft) do if group ~= nil and group:isExist() == true then local units = group:getUnits() for _i, unit in pairs(units) do local uPos = unit:getPoint() if (((uPos.x - zone.point.x)^2 + (uPos.z - zone.point.z)^2)^0.5 <= zone.radius) then local unitName = unit:getName() trigger.action.outText("This unit is in the mother lovin zone: "..unitName, 10) --other functions can be run here too. end end end end timer.scheduleFunction(unitsInZone, nil, timer.getTime() + 5) --will run the function every five seconds for the entirety of the mission end unitsInZone() --initiates the function
  7. Currently I am thinking you have to call the destroy function and then respawn the group with the added unit. Is there an easier way to add a unit, to an existing group, that was killed / destroyed back into that group to simulate a repair? Thanks in advance.
  8. This code should help, sorry, I mis-read what you posted earlier; for some reason I thought you wanted to delete some on a trigger at one time and some and a later time. This code works for me: do local statObj = coalition.getStaticObjects(2) --(1=Red 2=Blue) for i, static in pairs(statObj) do local staticName = static:getName() if string.match(staticName, "StaticDelete.*") then --test names are "StaticDelete" the .* tells is to ignore anything after this. static:destroy() end end end
  9. Updated the above code, if anyone is interested. Accepts both coalitions. If a proper tanker isn't available, i.e., need a boom but only basket is available, the aircraft ignores the command. No need to input aircraft names, automatically tracks all coalition aircraft that are refuellable in air and tasks them to refuel based on the parameters you set. You can set a parameter that if the aircraft is within x meters of base, it will ignore the task to refuel. Will update this, eventually, to add message to coalition when aircraft tasks to a tanker. lowFuelPercentage = 35 --number, percentage: percent when aircraft dips below that will prompt it to go for fuel lowFuelCheckTime = 60 --number, seconds: How often the function will check aricraft fuel levels lowFuelCoalition = "Blue" --string: "Both" or "Red" or "Blue" Which coalition are you sending to tanker distanceFromEnemy = 30000 --number, meters: 30km Not working at moment distanceFromBase = 92600 --number, meters: 92.6km (50nm) distance from final waypoint that a group will ignore the command to go to tanker aircraftTaskedToRefuel = {} function fuelTracker() local aircraftTable = {} local aircaftLowFuel = {} aircraftTable = populateAircraft() for i, grpName in pairs(aircraftTable) do if grpName ~= nil then if not aircraftTaskedToRefuel[grpName] then local group = Group.getByName(grpName) if group:isExist() == true then local closerToBase = areCloseToBase(grpName) if closerToBase == true then local units = group:getUnits() if units ~= nil then for x, unit in pairs(units) do if unit:hasAttribute("Refuelable") == true then if unit:hasAttribute("Tankers") == false then local fuel = unit:getFuel() if (fuel / .01) <= lowFuelPercentage then local groupName = unit:getGroup():getName() aircaftLowFuel[#aircaftLowFuel+1] = groupName end end end end end end end end end end for i, grpName in pairs(aircaftLowFuel) do if grpName then aircraftTaskedToRefuel[grpName] = {unitNo = {}} local group = Group.getByName(grpName) local units = group:getUnits() for x, unit in pairs(units) do aircraftTaskedToRefuel[grpName].unitNo[#aircraftTaskedToRefuel[grpName].unitNo+1] = {unitName = unit:getName(), unitFuel = unit:getFuel() / .01, unitCall = unit:getCallsign()} end end end for i, grpName in pairs(aircaftLowFuel) do if grpName then --local enemyNear = aircraftDetectedTars(groupName) --if enemyNear == false then goToTanker(grpName) aircaftLowFuel[grpName] = nil --end end end timer.scheduleFunction(fuelTracker, {}, timer.getTime() + lowFuelCheckTime) end function areCloseToBase(groupName) local points = mist.getGroupPoints(groupName) local maxWypt = 0 for i, v in pairs(points) do if i >= maxWypt then maxWypt = i end end local maxWyptPoint = points[maxWypt] local unitPos = Group.getByName(groupName):getUnit(1):getPoint() local distToHome = getDistanceAir(maxWyptPoint, unitPos) local maxDistFrom = distanceFromBase if distToHome >= maxDistFrom then return true else return false end end function checkForTanker(groupName) local side = Group.getByName(groupName):getCoalition() local groups = coalition.getGroups(side, 0) for i, group in pairs(groups) do if group then if group:isExist() == true then if group:getUnit(1):isActive() == true then if group:getUnit(1):hasAttribute("Tankers") == true then return true end end end end end end function goToTanker(groupName) local isTanker = checkForTanker(groupName) if isTanker == true then local group = Group.getByName(groupName) local task = { id = 'Refueling', params = {} } local controller = group:getController() controller:pushTask(task) end end refuelStopEvent = {} function refuelStopEvent:onEvent(event) if event.id == 14 and event.initiator:getPlayerName() == nil then local unit = event.initiator local group = unit:getGroup() --if #aircraftTaskedToRefuel[group:getName()].unitNo > 1 then --timer.scheduleFunction(removeGroupFromTasked, {group:getName()}, timer.getTime() + 20) --else timer.scheduleFunction(removeGroupFromTasked, {group:getName()}, timer.getTime() + 120) --end end end world.addEventHandler(refuelStopEvent) function removeGroupFromTasked(args) local groupName = args[1] aircraftTaskedToRefuel[groupName] = nil end function populateAircraft() local aircraftTable = {} local lowFuelCoaCheck = string.lower(lowFuelCoalition) if lowFuelCoaCheck == "blue" then local blueAircraft = coalition.getGroups(2,0) for i, ac in pairs(blueAircraft) do if ac ~= nil then if ac:isExist() == true then aircraftTable[#aircraftTable+1] = ac:getName() end end end end if lowFuelCoaCheck == "red" then local redAircraft = coalition.getGroups(1,0) for i, ac in pairs(redAircraft) do if ac ~= nil then if ac:isExist() == true then aircraftTable[#aircraftTable+1] = ac:getName() end end end end --lowFuelCoaCheck == "red" or "both" doesn't ****ing work... if lowFuelCoaCheck == "both" then local redAircraftAll = coalition.getGroups(1,0) local blueAircraftAll = coalition.getGroups(2,0) for i, ac in pairs(redAircraftAll) do if ac ~= nil then if ac:isExist() == true then aircraftTable[#aircraftTable+1] = ac:getName() end end end for i, ac in pairs(blueAircraftAll) do if ac ~= nil then if ac:isExist() == true then aircraftTable[#aircraftTable+1] = ac:getName() end end end end return aircraftTable end function getDistanceAir(point1, point2) local xUnit = point1.x local yUnit = point1.y local xZone = point2.x local yZone = point2.y local xDiff = xUnit - xZone local yDiff = yUnit - yZone return math.sqrt(xDiff * xDiff + yDiff * yDiff) end
  10. Yes it will. The only thing, that I am aware of, with fuel tanks is that -n aircraft will return greater than 1.00 or 100% with fuel tanks. So for example, when fully fueled with fuel tanks, a hornet might show 1.45 (145%) or whatever; I am making that up. But it will steadily reduce to 0 over time and doesn’t effect the script. Disclaimer: I haven’t tested this script without a tanker, meaning it might throw an error when tasking the AI if the tanker is killed, RTBs, or otherwise disappears from the missions. I am away from my desktop and will not be able to test it until later this week. But I will try to add something in anyway when I get time.
  11. Tasking an AI to go to the nearest tanker at a given fuel level is not challenging. The difficulty arises when deciding 1) when the aircraft should NOT go for fuel; and 2) after the aircraft is done refueling, what then? Once an AI is done refueling at a tanker, it will simply return to its route. And if the next route is return to base, it will do so. Example: if an aircraft is on its way to base from a mission, if it meets the parameters, i.e., below percentage of fuel, it could abandon its approach and attempt to go to the nearest tanker, which could be 200nm away. Here is a start. To run this: 1) change the names "Hornet", "Hornet2" in the aircraft table to the group names in the mission editor that you want to track. You can add group names to the table, just make sure they follow the same format, i.e., wrapped in "" followed by a comma. 2) Change the percentage to your liking. Right now its set to send the AI once the get to or below 30%. 3) Set how often you want the function to run. Currently, it will check every 30 seconds. You can change that to whatever you want. Make sure it is a number. 4) Set trigger in the mission editor "ONCE," no conditions, Do script, and paste the below code in the box. 5) Set another trigger with a time delay of whatever, 30 seconds, doesn't matter, but should be at least 1 second, Do script and paste fuelTracker() in it. This will run the function once, but then the function is built to repeat itself ever x amount of seconds (as you set in the lowFuelCheckTime parameter). I will add to this when I have time. Hopefully this will help you get started. lowFuelPercentage = 30 lowFuelCheckTime = 30 aircraftTable = { "Hornet", "Hornet2", } aircaftLowFuel = {} function fuelTracker() local tempTable = {} for i, grp in pairs(aircraftTable) do if grp ~= nil then local group = Group.getByName(grp) if group:isExist() == true then local units = group:getUnits() if units ~= nil then for x, unit in pairs(units) do tempTable[#tempTable+1] = unit:getName() end end end end end for i, val in pairs(tempTable) do if val ~= nil then local unit = Unit.getByName(val) local fuel = unit:getFuel() local fuelThresh = (lowFuelPercentage *.01) if fuel / 1 <= fuelThresh then local dispFuel = math.floor(fuel) local groupName = unit:getGroup():getName() if not aircaftLowFuel[groupName] then aircaftLowFuel[groupName] = {unitName = unit:getName(), fuel = unit:getFuel() / 1} end end end end for groupName, t in pairs(aircaftLowFuel) do if groupName then goToTanker(groupName) aircaftLowFuel[groupName] = nil end end timer.scheduleFunction(fuelTracker, {}, timer.getTime() + lowFuelCheckTime) end function goToTanker(groupName) local group = Group.getByName(groupName) local task = { id = 'Refueling', params = {} } local controller = group:getController() controller:pushTask(task) end
  12. Does anyone know if there is any function that can be used to determine, or any trigger that occurs, when all of the Airborne Group Units have loaded on to a Huey/Mi-8 when the player uses F7 menu? Alternatively, is there any way to figure out when a player presses the F7 Embark / Embarking / GroupName menu to figure out which unit / player has the group? Any input / feedback is appreciated. Thank you kindly.
  13. This may be a hardware issue. But, I was flying the Ka-50 post 2.20.2020 update and... I've had an erection lasting for more than four hours now so...
  14. Thanks for looking at this. See the attached tracks. The mission is the same mission, one was ran in stable version and the other was in open beta 2.5.6 just a moment ago. One thing I noticed that was different in 2.5.6 is the new "ALL" option under vehicle group. Pre 2.5.6 all was not an option and so long as the field was blank, either a UH-1 or Mi-8 was able to pick up the group. There are two infantry groups in the test: One is given the embark task at WP1; the others are auto tasked on event landing. Please let me know if you need anything else. Thanks again. server-20200216-132940 (run in beta 2.5.6).trk server-20200216-133340 (run in stable version).trk
×
×
  • Create New...