Water Level Fix

Post » Tue Jan 04, 2011 12:14 am

Well, since NoM is nearly done, I can start thinking to something else to work on...

One thing (bug?) that always gave me problems with NoM is the GetWaterLevel function. This function should be used to determine if an object is above or below the water level, but it has a heavy problem: if used in an interior cell that doesn't have water this function still returns a value, making the check unreliable. I know for sure that this problem is common to other mods as well, so I thought to find a solution, if possible.

I did a little testing and I discovered what follows.
If you get an interior cell with no water (Abaelun Mine, for example) a simple script checking the water level will tell you that you are under water, and that the water level is 0.
So I opened the cell properties in the CS and:
- enabled water (the water level is effectively above the cell ground)
- changed water level to -15000
- disabled water
Loaded the game and ta-daaaa! I'm now above water and the water level is -15000, even if there's no water in the cell.

So basically, it seems that GetWaterLevel effectively returns the exact water level even if water is disabled. But it seems too that if you change the water level and then disable water again, the new water level is remembered and returned. The weird thing is that, after disabling water, the water level for the cell is 0 (greyed out) in the CS and -15000 in game.
The solution is simple, maybe a bit boring: parse the interior game cells without water and lower their level if needed.

I have a few questions though:
1) Anyone can see problems in my idea? I don't want to change the water level of a thousand cells and the discover that it was useless.
2) Is there a mod that already does this?
3) What are the possible conflicts? Will this conflict with mods that change the light settings for the cells, since light and water settings are in the same tab, or the 2 changes will be merged? Changes to a cell usually get merged when loading, but for changes to a cell properties I'm not so sure...
User avatar
Danny Warner
 
Posts: 3400
Joined: Fri Jun 01, 2007 3:26 am

Post » Mon Jan 03, 2011 3:43 pm

The idea seems to work. :) I tested it with the NoM bedroll and campfire.
I went to Abaelun Mine and tried to put down the bedroll. I received the "You can't put a bedroll in water!" error, even if the cell has no water.
Then I activated the fix and returned to Abaelun Mine. This time I could place the bedroll and the campfire without problems!

I know this is a very specific fix, and yes, I'm doing it because I want NoM items to work without flaws. But I think and hope that being able to determine the exact water level of every MW+TB+BM cell will be a great help for many modders.

Since nobody is answering to the three questions in the post above, should I suppose they're a triple no? :P
User avatar
brian adkins
 
Posts: 3452
Joined: Mon Oct 01, 2007 8:51 am

Post » Tue Jan 04, 2011 12:06 am

-clip-
I have a few questions though:
1) Anyone can see problems in my idea? I don't want to change the water level of a thousand cells and the discover that it was useless.
2) Is there a mod that already does this?
3) What are the possible conflicts? Will this conflict with mods that change the light settings for the cells, since light and water settings are in the same tab, or the 2 changes will be merged? Changes to a cell usually get merged when loading, but for changes to a cell properties I'm not so sure...

Clever solution! :clap:
Why not just leave the water enabled? That should avoid future obsolescence if this problem is addressed by the Morrowind Code Patch (or another exe patch) in a way that would disregard values for cells with water flagged as disabled and instead reset the water level to a specific consistent value when that state exists.

I don't believe there is a mod that already does this.

I'll try and do some testing in regards to cell property merging - I'm of the impression that the AMBI and WGHT entries that the CS can introduce into a plugin will override those settings from an earlier loading esm/esp, which is why TESTool cleans them when they match exactly the values for the bethesda masters.


[edit] actually on second thought, it's probably better to disable the water again to preserve the original cell state of 'does not have water'. For example, the distant statics generator for MGE checks if an interior cell has water enabled to determine if the cell should be included when using the option to create statics for water reflections.
User avatar
bimsy
 
Posts: 3541
Joined: Wed Oct 11, 2006 3:04 pm

Post » Mon Jan 03, 2011 11:18 am

Then I'll leave water disabled for sure, I don't want to create problems with MGE. :)
I've started to seriously parse the game interior cells. I've completed letter A and B (which includes all Ald-Ruhn and Balmora interiors), changing the water level for cells that needed it.
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am

Post » Mon Jan 03, 2011 2:26 pm

Maybe john.moonsugar can add it to his "multipatch"-feature for tes3cmd.
User avatar
sw1ss
 
Posts: 3461
Joined: Wed Nov 28, 2007 8:02 pm

Post » Mon Jan 03, 2011 12:01 pm

Maybe john.moonsugar can add it to his "multipatch"-feature for tes3cmd.

tes3cmd could probably do this already, with a little bit of perl code mixed into the "modify" command.

Is the solution as simple as setting the WHGT to -15000 for all interior cells that have water disabled?
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm

Post » Tue Jan 04, 2011 12:26 am

tes3cmd could probably do this already, with a little bit of perl code mixed into the "modify" command.

Is the solution as simple as setting the WHGT to -15000 for all interior cells that have water disabled?

Yes, it seems to work from my tests. The majority of MW interior cells (at least the ones I checked till now) are built around the 0 z level, so that water level cuts them in half. A few cells are built at high z, like 10000 or 15000, but I'd say that none goes below -2000. So -15000 seems a safe level for me, but you can use anything low enough.
It would be great if you could do this in an automated way, hehe. You know, I can do it manually, but changing all those cells is a bit boring. :P
User avatar
ruCkii
 
Posts: 3360
Joined: Mon Mar 26, 2007 9:08 pm

Post » Mon Jan 03, 2011 1:39 pm

It would be great if you could do this in an automated way, hehe. You know, I can do it manually, but changing all those cells is a bit boring. :P

Okay, let me know if http://www.sendspace.com/file/uqzqf1 works. It patches 941 interior cells that had water disabled to set the WHGT sub-record to -99999.

This is an example of what each cell record inside will look like:
Record: CELL "abaelun mine" Flags:0x0000 ()  NAME: Name:Abaelun Mine  DATA: (Interior) Fog_Density:1.00  Flags:0x0001 (Illegal_To_Sleep_Here)  WHGT: Water_Height:-99999.00

User avatar
Quick Draw
 
Posts: 3423
Joined: Sun Sep 30, 2007 4:56 am

Post » Mon Jan 03, 2011 4:37 pm

Okay, let me know if http://www.sendspace.com/file/uqzqf1 works. It patches 941 interior cells that had water disabled to set the WHGT sub-record to -99999.

This is an example of what each cell record inside will look like:
Record: CELL "abaelun mine" Flags:0x0000 ()  NAME: Name:Abaelun Mine  DATA: (Interior) Fog_Density:1.00  Flags:0x0001 (Illegal_To_Sleep_Here)  WHGT: Water_Height:-99999.00

It works perfectly!
With the plugin activated, I can set up NoM fires and bedrolls in the right way. If I disable it, I get back the "you're under water" message.
Even better, using tes3cmd only the WGHT of each cell is changed, while doing it by hands would have changed the light settings too. This should prevent conflicts with light changing plugins, if loaded after them.

Well, have we finally defeated a 8-year old annoyance? :celebration:
User avatar
Dylan Markese
 
Posts: 3513
Joined: Sat Dec 01, 2007 11:58 am

Post » Mon Jan 03, 2011 12:02 pm

It works perfectly!
With the plugin activated, I can set up NoM fires and bedrolls in the right way. If I disable it, I get back the "you're under water" message.
Even better, using tes3cmd only the WGHT of each cell is changed, while doing it by hands would have changed the light settings too. This should prevent conflicts with light changing plugins, if loaded after them.

Well, have we finally defeated a 8-year old annoyance? :celebration:


Cool, for future reference, here's how I did it with tes3cmd:

First, create a new plugin (water.esp) that contains all the interior cells that do not have the "Has_Water" flag:
tes3cmd dump --raw-with-header water.esp --type cell --interior --no-match 'Interior.*Flags:.*Has_Water' Morrowind.esm


Now delete all the object instances (references) from all the cells in our new water.esp:
tes3cmd delete --type cell --instance-match . water.esp > junk.log


Delete all the other stuff from cells, so that only the NAME and DATA sub-records remain:
tes3cmd delete --sub-match "^(water_height|ambient|reference_count):" water.esp


Do a little perl-fu to add a new WHGT sub-record to each cell in water.esp:
tes3cmd modify --type cell --run "$R->append(CELL::WHGT->new({water_height=>-99999}));$R->{_modified_}=1;" water.esp


And that results in the "water.esp" that I uploaded.

(I did this on Linux, and tried to show how they commands are invoked under Windows, hope I didn't make a mistake).

Edit: so it would be easy to add in cells for Tribunal and Bloodmoon too.
User avatar
james kite
 
Posts: 3460
Joined: Sun Jul 22, 2007 8:52 am

Post » Mon Jan 03, 2011 8:10 pm

Cool, for future reference, here's how I did it with tes3cmd:

First, create a new plugin (water.esp) that contains all the interior cells that do not have the "Has_Water" flag:
tes3cmd dump --raw-with-header water.esp --type cell --interior --no-match 'Interior.*Flags:.*Has_Water' Morrowind.esm


Now delete all the object instances (references) from all the cells in our new water.esp:
tes3cmd delete --type cell --instance-match . water.esp > junk.log


Delete all the other stuff from cells, so that only the NAME and DATA sub-records remain:
tes3cmd delete --sub-match "^(water_height|ambient|reference_count):" water.esp


Do a little perl-fu to add a new WHGT sub-record to each cell in water.esp:
tes3cmd modify --type cell --run "$R->append(CELL::WHGT->new({water_height=>-99999}));$R->{_modified_}=1;" water.esp


And that results in the "water.esp" that I uploaded.

(I did this on Linux, and tried to show how they commands are invoked under Windows, hope I didn't make a mistake).

Edit: so it would be easy to add in cells for Tribunal and Bloodmoon too.

I'll try that to build an addon with Tribunal and Bloodmoon cells then.
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am

Post » Mon Jan 03, 2011 7:41 pm

What's the use of this? Can't follow... :P
User avatar
Vicki Blondie
 
Posts: 3408
Joined: Fri Jun 16, 2006 5:33 am

Post » Mon Jan 03, 2011 2:13 pm

I'll try that to build an addon with Tribunal and Bloodmoon cells then.

Let me know if you need help. The main difference in command lines between Linux and Windows is that you have to use double-quotes on Windows where I used single-quotes on Linux. I forgot to change them in one of the commands.
User avatar
Quick draw II
 
Posts: 3301
Joined: Thu Nov 08, 2007 4:11 pm

Post » Mon Jan 03, 2011 3:46 pm

What's the use of this? Can't follow... :P

Basically, in the majority of interior cells with water disabled, Morrowind believes that the player is under water (even if, as I said, there's no water at all). This causes buggy behaviour of all mods that need to check if the player is above or below water. For example, in NoM you can't light a fire or drop a bedroll in those interior cells, because the game believes you're under water. :brokencomputer:
This plugin will fix the problem, making the water level checks reliable.
User avatar
evelina c
 
Posts: 3377
Joined: Tue Dec 19, 2006 4:28 pm

Post » Mon Jan 03, 2011 11:17 am

Basically, in the majority of interior cells with water disabled, Morrowind believes that the player is under water (even if, as I said, there's no water at all). This causes buggy behaviour of all mods that need to check if the player is above or below water. For example, in NoM you can't light a fire or drop a bedroll in those interior cells, because the game believes you're under water. :brokencomputer:
This plugin will fix the problem, making the water level checks reliable.


This is also why my companion tries to put on her swim suit whenever she goes into a dungeon. I'd been going crazy trying to figure that out.
User avatar
stephanie eastwood
 
Posts: 3526
Joined: Thu Jun 08, 2006 1:25 pm

Post » Mon Jan 03, 2011 12:48 pm

Let me know if you need help. The main difference in command lines between Linux and Windows is that you have to use double-quotes on Windows where I used single-quotes on Linux. I forgot to change them in one of the commands.

I only had to replace ' with " in the first command. Everything else worked without problems and now I've a plugin for Tribunal and one for Bloodmoon too. I'm building a merged version right now.

This is also why my companion tries to put on her swim suit whenever she goes into a dungeon. I'd been going crazy trying to figure that out.

Let's hope this will solve the problem, then. :)
User avatar
Adam Baumgartner
 
Posts: 3344
Joined: Wed May 30, 2007 12:12 pm

Post » Mon Jan 03, 2011 11:53 pm

I'm uploading it to PES, I'll make a release thread when it's online.
User avatar
Javaun Thompson
 
Posts: 3397
Joined: Fri Sep 21, 2007 10:28 am

Post » Mon Jan 03, 2011 11:12 pm

Just out of curiosity, what is the time for approval on PES? I uploaded the fix 2 days ago but it's still pending.
User avatar
Chelsea Head
 
Posts: 3433
Joined: Thu Mar 08, 2007 6:38 am

Post » Mon Jan 03, 2011 2:26 pm

Maybe with this little fix I won't occasionally see Abot's Water Life fish swimming around the interiors of houses anymore.
User avatar
Avril Churchill
 
Posts: 3455
Joined: Wed Aug 09, 2006 10:00 am

Post » Tue Jan 04, 2011 2:11 am

so this only effects cells that dont have the water level box ticked right?
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Mon Jan 03, 2011 12:07 pm

Sorry, the last two questions somewhat eluded me...
Maybe with this little fix I won't occasionally see Abot's Water Life fish swimming around the interiors of houses anymore.

Yes, that's the idea. This fix is aimed to solve that kind of problems. :)

so this only effects cells that dont have the water level box ticked right?

Yes, that's right. Cells with water are left untouched.
User avatar
Kieren Thomson
 
Posts: 3454
Joined: Sat Jul 21, 2007 3:28 am


Return to III - Morrowind