Jump to content

Creating a zone from marker coordinates


Darcaem

Recommended Posts

Hi

 

I would like the ability to spawn AI flights with different basic missions as support, headed roughly to a certain area the player could choose. For that I was planning to use the AUFTRAG class from MOOSE. And as a first test to validate it and learn how to use it I thought on this method:

 

1.- Create a marker on the F10 map and get its coordinates

 

markerCoordinates = {}

local MarkHandler = {}
function MarkHandler:onEvent(event)
    if event.id == 25 then 		
		markerCoordinates = POINT_VEC2:New(event.pos.x, event.pos.y)
    end       
end
world.addEventHandler(MarkHandler)

 

2.- Choose via F10 menu what base, mission and aircraft I would like to spawn

3.- Spawn selected aircraft

4.- Create a zone using the ZONE_RADIUS:New() method, based on the marker's coordinates

5.- Create a mission (for now I've only tried CAP) and assign it to the flight

 

function launchFlight(from, aircraft, number, task, zone) 
	dofile("./syria/airbases/"..from.."/aircraft.lua")
	
	-- Check how many aircrafts are available
	local num = Aircraft[aircraft]
	
	if (num ~= nil and num >= number) then
		
		-- Remove static placeholders 
		for i = 0, number-1, 1 do
			local value = num - i
			local static = STATIC:FindByName(from.." "..aircraft.." "..value)
			static:Destroy()
		end

		-- Update logistics
		Aircraft[aircraft] = num - number
		writeAircraft(from)
		
		-- Launch flight
		local airbase
		if (from == "RamatDavid") then
			airbase = AIRBASE:FindByName(AIRBASE.Syria.Ramat_David)
		elseif (from == "Incirlik") then
			airbase = AIRBASE:FindByName(AIRBASE.Syria.Incirlik)
		end
		SpawnArray[from][task][aircraft]
			:OnSpawnGroup(
				function( SpawnGroup )	
					local mission
					if (task == "CAP") then
						local zone = ZONE_RADIUS:New("ZonaTest", markerCoordinates, 100000)
						mission = AUFTRAG:NewCAP(zone)
					elseif (task == "SEAD") then
					
					end
			
					local fg=FLIGHTGROUP:New(Group.getByName(SpawnGroup.GroupName))
					fg:AddMission(mission) 
				end
			)
			:SpawnAtAirbase(airbase, SPAWN.Takeoff.Hot )
	else 
		trigger.action.outText(aircraft.." not available on "..from,20)
	end	
end

 

What happens is that the flight is correctly spawned, taxi and takeoff as usual, but it RTB inmediatelly after takeoff. If I use instead a zone directly defined on the mission editor, it works correctly and the flight goes to the CAP zone. So my guess is the zone assigned to the Auftrag's generated CAP is wrong, and my second guess is that the problem are the coordinates I'm using as secont parameter on the ZONE_RADIOUS:New() method

 

What am I doing wrong?

 

PD: I have been using and customizing to my liking Surrexen's awesome sandbox missions for a while. In those, he defines on ME a lot of different templates and routes, one for each area of the map. I'm trying to give (me) a litle more freedom, allowing to direct flights in real-time, not to predetermined locations, just to play around and see if it the AI can be more accuratelly directed on a sandbox scenario.

 

PD2: I might end up discovering CA's ability to "control" flights is enough, and these weekends programming and testing random stuff have been a waste of time 😛

 

Link to comment
Share on other sites

I know your pain..     I'm trying to return the current location of a client control unit.. EG ka-50 but so far I'm failing miserably, 

Targs,

 

 

 

GTX 1080ti, Asus Hero XI, Intel 9900KF @4.2MHz, 32g DDR4@3200Mhz, 4x 1Tb SSD 1x 400g m.2mvme(boot), 28" Samsung 4k, Saitek X-56 Throttle/Warthog Stick and Saitek Pro Flight Pedals.

 

 

Moduls

 

 

All of the NATO jets, and all the choppers..

DEDi MP [62AW] The Blackbirds Brisbane

 

 

Link to comment
Share on other sites

If you just need to locate the player's location I believe you just need to find the GROUP object with

GROUP:FindByName()

for example and then you have a GetCoordinate method.

 

https://flightcontrol-master.github.io/MOOSE_DOCS/Documentation/Wrapper.Group.html##(GROUP).GetCoordinate

 

I have done that to create a markers indicating the last known location of downed pilots, for CSAR missions. If you have problems, I can search the script I used.

 

Nevertheless, I assume you have multiple clients and your problem resides in identifying what GROUP is the one you want, doesn't it?

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

In case anyone ever reads this, I found my error. Turns out that the event.pos object y compnent is the altitude, so the correct way of creating a POINT_VEC2 object from an event object is 

 

markerCoordinates = POINT_VEC2:New(event.pos.x, event.pos.z)

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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