Jump to content

Recommended Posts

Posted

Hi,

I have the following code below. Using the F10 menu, that allows a player in a helicopter can create a FARP 100m in front of them. (This is just for testing at the moment). 

The problem I have, is when the new FARP is created, it doesn't appear to be available in the dynamic spawn slot list. I can see the original static FARP created via the ME in the dynamic spawn list, but not the newly created FARP.

I have attached a working copy of the mission - to replicate simply start a multiplayer server, spawn into the UH-1 and choose spawn farp from the F10 menu. 

Thanks & Regards

DZ

 

-- Define the function to create a static FARP at a given position
function createFARP(position)
    local farp = {
        ["category"] = "Heliports",
        ["shape_name"] = "FARP", -- Full FARP shape name
        ["type"] = "FARP",
        ["unitId"] = mist.getNextUnitId(), -- Ensure this function is available in your environment
        ["x"] = position.x,
        ["y"] = position.z, -- Note: 'y' in DCS is actually the z-axis for world coordinates
        ["name"] = "Spawned FARP",
        ["heading"] = 0,
        ["dead"] = false,
        ["dynamicSpawn"] = true,
    }
    coalition.addStaticObject(country.id.USA, farp)
end

-- Define the function to get player coordinates, display them with an offset, and create a FARP
function getPlayerCoordinates(unit)
    if unit then
        local unitPosition = unit:getPosition().p
        local unitOrientation = unit:getPosition().x

        -- Normalize the forward vector
        local forwardVector = {
            x = unitOrientation.x,
            y = unitOrientation.y,
            z = unitOrientation.z
        }
        local length = math.sqrt(forwardVector.x^2 + forwardVector.y^2 + forwardVector.z^2)
        forwardVector.x = forwardVector.x / length
        forwardVector.y = forwardVector.y / length
        forwardVector.z = forwardVector.z / length

        -- Apply the 100m offset
        local offsetPosition = {
            x = unitPosition.x + forwardVector.x * 100,
            y = unitPosition.y + forwardVector.y * 100,
            z = unitPosition.z + forwardVector.z * 100
        }

        -- Display the offset coordinates
        local lat, lon, alt = coord.LOtoLL(offsetPosition)
        trigger.action.outTextForUnit(unit:getID(), string.format("Your offset coordinates:\nLatitude: %.6f\nLongitude: %.6f\nAltitude: %.1f meters", lat, lon, alt), 10)

        -- Create the FARP at the offset position
        createFARP(offsetPosition)
    else
        trigger.action.outText("Unit not found.", 10)
    end
end

-- Add the F10 menu for a group
function addF10MenuForGroup(group)
    if group then
        for i = 1, #group:getUnits() do
            local unit = group:getUnit(i)
            if unit then
                missionCommands.addCommandForGroup(group:getID(), "Get Offset Coordinates and Create FARP", nil, getPlayerCoordinates, unit)
            end
        end
    end
end

-- Iterate over all groups and add the F10 menu
function addF10MenuForAllPlayers()
    local coalitionGroups
    -- Process helicopter groups for both sides
    coalitionGroups = coalition.getGroups(coalition.side.BLUE, Group.Category.HELICOPTER)
    for i = 1, #coalitionGroups do
        addF10MenuForGroup(coalitionGroups[i])
    end
    
end

-- Schedule the menu addition
do
    addF10MenuForAllPlayers()
end

 

DynamicFarp.miz

Posted

OK - I've found one way for this to be successful - but it requires 'hacking' the DCS install. I'm not sure whether this is just a server side thing (if so, it may mean that us mission hosters may be able to have dynamic spawning on dynamically spawned FARPS moving forward)!

It involves editing the Scripts\ui\MultiplayerSelectRoleMap\MultiplayerSelectDynamicDialog.lua file, and commenting out certain IF statements so that the dynamic spawn will spawn regardless. (Note: This has the sideeffect that dynamic spawn will always be available for all airfields, as it ignores the dynamic spawn true/false in the mission file). 

I'm hoping there's a more eloquent way of achieving this that doesn't involve modifying (hacking) the .lua file on the server.

 

function getAllDynamicsAirdromes()
    airdromes = Terrain.GetTerrainConfig("Airdromes")
    local dynamicsAirdromes = {}
    for i, v in pairs(airdromes) do
        local settings = DCS.getDynamicSpawnSettings(i, true)
        --if settings.dynamicSpawnAvailable == true then
            base.table.insert(dynamicsAirdromes, i)
        --end
    end
    return dynamicsAirdromes
end

function isDynamicSpawnAllowForAirbase(airbaseId, isAirdrome)
--	local settings = DCS.getDynamicSpawnSettings(airbaseId, isAirdrome)
--	if settings and settings.dynamicSpawnAvailable == true then
		return true
--	end
	
--	return false
end

function getDynamicsAirdromes(coalition)
	local dynamicsAirdromes = {}
	
	airdromes = Terrain.GetTerrainConfig("Airdromes")

	for i, value in pairs(DCS.getAirdromesCoalition()) do
		airdromesCoalitions[value.airdromeId] = coalitionIndices[value.coalition]
	end
	
	for i, v in pairs(airdromes) do
		local settings = DCS.getDynamicSpawnSettings(i, true)
		--if settings and settings.dynamicSpawnAvailable == true and coalition == airdromesCoalitions[i] then
		if settings and coalition == airdromesCoalitions[i] then
			v.airdromeId = i
			v.airbaseType = _('Airfield')
			base.table.insert(dynamicsAirdromes, v)
		end
	end
	return dynamicsAirdromes
end

function getDynamicsFarpsAndCarriers(coalition)
	local farpsAndCarriersData = {}
	
	local addFunc = function(data, airbaseType)
		for i, v in pairs(data) do
			local settings = DCS.getDynamicSpawnSettings(i, false)
			--if settings and settings.dynamicSpawnAvailable == true and coalition == v.coalition then
			if settings  and coalition == v.coalition then
				v.unitId = i
				v.airbaseType = airbaseType
				base.table.insert(farpsAndCarriersData, v)
			end
		end
	end
	
	local farpsAndCarriers = DCS.getFarpsAndCarriersMissionData()
	addFunc(farpsAndCarriers.farps, _('Heliport'))
	addFunc(farpsAndCarriers.carriers, _('Aircraft carrier'))
	return farpsAndCarriersData
end

 

 

  • Like 3
Posted

Just to share, as a result of looking into some warehouse functions for dynamic FARPs (arming/fueling, not spawning), there is another mechanism that involves reserving warehouse IDs and having limited dynamic spawning FARP availability detailed here.

  • Thanks 1
  • 4 months later...
  • ED Team
Posted
9 hours ago, shaji said:

@BIGNEWY Any news on this? Dynamic spawns for dynamically spawned FARPs is huge since most of the missions have CTLD. Thank you.

I will ask the team 

  • Thanks 1

smallCATPILOT.PNG.04bbece1b27ff1b2c193b174ec410fc0.PNG

Forum rules - DCS Crashing? Try this first - Cleanup and Repair - Discord BIGNEWY#8703 - Youtube - Patch Status

Windows 11, NVIDIA MSI RTX 3090, Intel® i9-10900K 3.70GHz, 5.30GHz Turbo, Corsair Hydro Series H150i Pro, 64GB DDR @3200, ASUS ROG Strix Z490-F Gaming, PIMAX Crystal

  • 2 months later...
  • 1 month later...
  • 3 weeks later...
Posted
On 12/3/2024 at 7:03 PM, BIGNEWY said:

I will ask the team 

Hi Bignewy,

Did ED ever get back to you since Dec about this? 

Just getting a little worried that we've heard nothing since. I appreciate that ED have a lot to do, but just a bone thrown our way so we have an idea of what the future looks like for the possibility with our mission making would be very welcome. 

Cheers

DZ

  • 2 months later...
Posted (edited)

Hi @BIGNEWY

I got excited seeing the change note for DCS 2.9.17.11733

Quote

GUI. Dynamically spawned FARPs via script do not show in dynamic spawns interface - fixed.

Unfortunately - it seems that this only works if you are the MP server host - and it is not synchronized to connected clients

Using the attached mission file

If you start MP from the Multiplayer menu, jump into the truck, use the F10 menu to spawn the farp, we can see that the FARP is created, and the dynamic spawn menu is activated and populated with our new farp.

If we run the same mission on a dedicated server - once the FARP is created - it is shown on the map, we can have the server query the warehouse content but the dynamic spawn menu remains unavailable

If we add debugging to `Scripts\UI\MultiplayerSelectRoleMap\MultiplayerSelectDynamicDialog.lua` we can see that neither the FARP name, nor DCS.getDynamicSpawnSettings response is synchronized to the client showing the farp has no name, and the settings do not allow dynamicSpawn / hotspawn

LuaGUI (Main): --dbg-- farps:90210
LuaGUI (Main): --dbg-- farps:90210 => y => 501000
LuaGUI (Main): --dbg-- farps:90210 => x => -499000
LuaGUI (Main): --dbg-- farps:90210 => name => 
LuaGUI (Main): --dbg-- farps:90210 => coalition => blue
LuaGUI (Main): --dbg-- farps:90210 => type => FARP

LuaGUI (Main): --dbg-- addFunc - dynamicSpawnAvailable => false
LuaGUI (Main): --dbg-- addFunc - allowHotSpawn => false

Here is a video showing both of the above routes

This patch has also impacted the previous workaround of pre-creating warehouse entries in the "warehouses" file within the mission - and this workaround no longer works 

Track file as client running the server: server-20250622-145021.trk
Track file from client of server: farp-sync-bug-20250622-145058.trk

Example Mission FIle: farp-sync-bug.miz

Thanks,
Martin

Edited by MartinCo
  • Like 3
Posted

It does not work for dedicated servers as well. 


Please fix! waiting to add this on 5 missions that the public will use 😃

  • Like 3
  • Recently Browsing   0 members

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