In a spare half hour or so I took the time to test out some things I had been wondering about with water in SWBF. The most interesting (and successful) of which was editing the water's settings like height and what not while a map was running. I'm not sure how useful this information will be, but SWBFII does have the scripting capabilities to take advantage of it so I'll post it here.
So the theory is quite simple. Inside a terrain chunk there is a WATR chunk, inside that is all the information about water for the terrain. That chunk has multiple chunks in it, one of which is LAYR. It has the following layout.
Code: Select all
char[] water texture // null terminated variable length string. There will always be at least one null character even if the texture is unset.
int32 unknown // I don't know what it is, maybe it's what keeps the Earth from exploding.
float height // The height of all water in the map.
float u velocity // The U vel value of the water.
float v velocity // The V vel value of the water.
float u repeat // The U rept value of the water.
float v repeat // The V rept value of the water.
uint[4] colour // rgba colour of the water.
The total size of the chunk with an empty water texture is 29 bytes. Now what's interesting here is that we can strip away all the other nonsense from a terrain chunk and leave only the WATR chunk with only the LAYR chunk in it and the game will still load it and apply the water settings accordingly. This works even when ingame, leading to the distinct possibility of creating a map that floods or something.
In order to exploit this you can grab
this premade ucfb file that is all setup for this. After that using it is as simple as putting the file in your map's _LVL_PC folder (of course I would personally organize it a bit more). And the wherever you wish to change the water settings in your script put.
Code: Select all
ReadDataFile("dc:settings.water")
-- Or for Lua hipsters
ReadDataFile "dc:settings.water"
After that you're new water settings will take effect. Of course you'll probably want to edit the "settings.water" file in your favourite hexeditor to have the settings you want. (See the layout earlier in the post for how to do this.) If someone was wanting to get really fancy you could probably even create this file dynamically from within Lua; only thing is you would have a lot of fun encoding floats without access to integers or bit shifting.