• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

AICreateSimulatedObject / Enum problem

Messages
30
Hi all,
I am currently trying to write a program (C#) which add scenery objects via AICreateSimulatedObject when the user flies within a defined area.
When starting the program it does not know what objects to show later (feed by xml files from a web server). And it can happen that objects change on runtime.

The code to show a object would be something like this:

Code:
simconnect.AICreateSimulatedObject("de Havilland Dash 8-100", initpos, REQUEST_ID.Plane1)

Problem: How do I add / remove / change elements in the EQUEST_ID enum on runtime?
And how to insert the correct enum value in the function call.

greez bergziege

Ps.: the big G could't help me so far.
 
I generally do something like this:

DATA:
Code:
enum Requests
{
    SomeRequest,
    AnotherRequest,

    AIAircraftBase =   0x00100000,
    OtherRequestBase = 0x00200000,
}

uint AircraftCount = 0;

and in the code when creating a new aircraft:
Code:
    AircraftCount++;
    sc.AICreateSimulatedObject("de Havilland Dash 8-100", initpos, (uint)AIAircraftBase + AircraftCount);

and in any OnRecvXxx handler that deals with this value coming back:
Code:
    if (dwRequestID >= (uint)AIAircraftBase && 
        dwRequestID < (uint)AIAircraftBase + 10000) // choose some max number of objects you will create at one time
    {
        // do something relevant here
    }

I do the same sort of thing for tracking existing AI Objects when doing the RequestDataOnSimObject calls, except I add the dwObjectID to the XxxBase value to get a unique ID value.

There's nothing in the SDK that says the Request ID values have to be sequential, just unique. And they only need to be unique from the standpoint of currently outstanding requests - meaning, in your example situation, if you will only ever be creating one AI object at any given time, then you could use the same request ID everytime, you would only need unique IDs if you were going to call this several times at roughly the same time (say inside a foreach loop).
 
beatle, you are my hero!

Your thing with the AIAircraftBase helped me a lot.

I am now making good progress with my web-based multiplayer scenery engine *g*

Thank you!
 
Hi All,

Just to chime in here rather than make a new thread...

I take it it's possible to create a specific AI aircraft at a specific location with SimConnect? i.e. in the same manner as above?

I need to create specific aircraft parked on the ground (although if it's possible to feed them a flight plan, that would also be good), and I'm just wading through the SDK at the moment to see if it's possible.

Sounds like it is though?

(I'm not up on SimConnect as I usually use FSUIPC).

Cheers,
S
 
Hi, its possible for all kind of sim objects (and scenery libraries via fake simobjects).

there is an good example within the SDK (Core Utilities Kit -> SimConnect SDK -> SimConnect ... scroll all the way down to the examples). Called AI objects and waypoints / Managed AI waypoints.

Source code is also avaiable under \Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\SimConnect SDK\Samples


greez bergziege
 
Back
Top