Jump to content
The simFlight Network Forums

How can I get multiple engine failure in MSFS20?


Recommended Posts

Hello everyone,

I'm currently working on a plugin to allow for custom engine failures in MSFS20 and I'm using C# with the NuGet FSUIPC Module.

So far I've got the following:

```

private Offset<uint> engine_failure = new Offset<uint>(0x0B6B);

...

// Fail engine 1

engine_failure.Value = 1;

// Fail engine 2

engine_failure.Value = 2;

// Fail engine 3

engine_failure.Value = 3;

// Fail engine 4

engine_failure.Value = 4;

```

However the issue is that if I fail engine 1 and then fail engine 2, engine 1 will come back alive since `engine_failure.Value` only takes one number (0,1,2,3,4).

 

Is there any way I can fix this? Is there some sort of hidden offset to fail individual engines?

 

Any help would be greatly appreciated!

-T

Link to comment
Share on other sites

Hi T,

This offset doesn't take the engine number like that. As the offsets document says, each bit  in the offset represents an engine. So bit 0 is engine 1, bit 1 is engine 2 etc. If the bit is set to 1 the engine is failed. If 0 it's working ok.

The easiest way to work with bits using the DLL is to declare the offset as an FsBitArray:

private Offset<FsBitArray> engine_failure = new Offset<FsBitArray>(0x0B6B, 1);

Note that the 1 (second parameter) is the length of the offset. This is required for some types like FsBitArray. 1 here means 1 byte as can been seen in the offsets documentation.

To access the individual bits in the offset use the following:

	if (engine_failure.Value[1])
	{
		// engine 2 has failed
	}

 

            engine_failure.Value[0] = true; // Set engine 1 to failed
            engine_failure.Value[3] = true; // Also set engine 4 to failed

 

Another thing you need to be aware of is that you declared this offset as uint which is 4 bytes, but the documentation says this offset is only one byte. If you declare offsets with the wrong type you're going to have problems with the values you read, and writing offsets with the wrong type will result is unexpected things happening in the sim.

Paul

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.