Custom Weather in Ambience Volumes

Hey there, I’ve been working on revising the weather events on my map, and have been using Ambiance volumes along with the Weather Types system in the Level file to try to create areas that have unique / local weather.

This hasn’t gone badly, but I’ve found myself running into a wall with the way that the Weather Masks work. I read into the documentation on it here:

and realized that the way certain volumes allow one weather type vs another in it is by using a Bitmask as described here:

So I’ve gone down the rabbit hole of learning about Bitmasks, and I understand the basic idea of how they work, and I understand how 0b01 represents bitmask 1, 0b11 represents the combination of 1 (0b01) and 2 (0b10), and all that described in the second doc.

My question now is how do a utilize this to restrict or allow for specific weather events?

For example I’ve added a new weather type that’s on mask 3, in binary this should be 0b11, which is also the same value as 1 and 2 being combined. How would I go about combining mask 3 and 1 so it can only do my custom weather event and rain in that volume (Would I just do the math for combining them and make a number that’s longer?).

What if I wanted to have my custom weather event but no rain or snow, if I do 3(0b11) it will allow all of them.

I’m not entirely sure where to go from this point. In addition, the mask for old volumes before this change were values like “4294967295”, and these seem to allow for all weather events. In binary this is just all 1s, which would be the combination of all weather masks enabled?

Ultimately I’m just confused about how I should combine the masks to make a binary number that I can then convert into the actual mask number that gets the desired combination of weather events within the volume.

Thanks to anyone who reads through this, as I’m not entirely sure what I’m talking about and it’s probably pretty confusing to read too!

To clarify a bit more. It seems “4294967295” is a 32bit integer with all values set to 1. A better question may be to ask what sections of this integer “11111111111111111111111111111111” should be toggled to get various effects (ie mask 2 (0b10) but NOT Mask 1 (0b01)) in that integer.

So I think I might understand how it works now?

Since Rain is Mask 1 (0b01) and snow is Mask 2 (0b10) you can use 3 to enable both (0b11), as both parts are set to 1.

If this is true, then 4 (0b100) would allow for neither 1 nor 2, since both sections are set to zero.

Then lastly, 5 (0b101) Would therefore allow mask 4 and mask 1 since both sections are set to 1, but not 2 because the middle is still 0.

I think this is how it works, but would love if anyone who has more knowledge on this could let me know.

Yea that’s the gist. Unturned uses bitmasks for the weather volumes. The documentation links to this wikipedia article that has more info.

I wrote a short little internal guide for myself when these first came around. I’ll paste it below.


Assuming you’re on Windows 10, you can open up your calculator and set it to Programmer Mode, from there you can switch to the Bit Toggling Keypad, it makes things easier. The two values that are relevant to you are the DEC values (which is what you’ll put into Unturned) and the BIN value, looking at that will make things easier to understand.

You can click on the bits to get values. If you’re setting up your own weather, then click just a single bit. If you wanted to enable weather marked as 8 (3), 16 (4) and 128 (7) in your volume, set your BIN value to “0100 1100”. You should get a value of 76, that’s the value you’d put in your volume.
Imgur

The Bitmasks for the weather are set in their .asset files. The weather a map uses is set in it’s “Level.Asset” file. (See Unturned/Bundles/Assets/Levels for examples)

TLDR: “12 is a combination of bit index 2 (4) and bit index 3 (8), a weather with the value 12 would active in any volume that also had bit index 2 or index 3.”

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.