Jump to content

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 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.