Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Determining when an object is in water


Malonn
 Share

Recommended Posts

How can I determine if an object is in water?  Not an actor, but a torch dropped to the ground.  I tried "IsSwimming" with the torch and it didn't work.  The player doesn't need to be in the water.  Sometimes a cell has water and the dropped torch slides into the water.  I want it to extinguish when that happens.  Extinguishing flames is simple.  But I'm having trouble figuring out how to determine when the torch slips into the water. 

Link to comment
Share on other sites

I've never needed to do this, but one thing you'll have to address is what it means to be "in water". For instance, if I put my toe into a bathtub, am I "in water" or "out of water"?

 

If you are content to use the geometric origin point (not necessarily the center) of the object, you might be able to use GetParentCellWaterHeight (an OBSE function) to get the Z coordinate of water in the containing cell. Then use GetPos Z on the object to see if its origin is lower than the water height. Since it's not possible (as far as I am aware) to have dry areas within a cell that are below the cell's water height, you don't have to care about the X and Y positions of the object within the cell.

 

At best, this would only be an approximation, but if you happen to know the shape of the object in question and how its origin relates to its visual center point, you might be able to work with this by applying a constant offset to the Z coordinate math to reflect how you want the thing to behave visually. For example, if your object is a sphere of 5 game units radius, and you know that its origin is its center, then artificially adding 5.0 to the object's Z coordinate before comparing it with the cell water height would tell you if the object is completely submerged. I know that's a trivial example, easy to calculate, and I only hope your actual need is not too complex. :-)

 

Hope this helps!

Link to comment
Share on other sites

That did more than help, syscrusher, it solved my problem.  By getting the cell's water height and checking that against the torch's height, the torch now goes out when entering water.  I haven't thoroughly tested, but I wonder what would happen in an interior cell that has water above the lowest point??  It wouldn't function as intended in that case I suspect.  I hope there are no cells like that.  Do you know of any?  There could be a pool of water, and later sections of the cell slope downhill or have steps going down into the dungeon.  Don't know, but for now, all is good.

 

THANKS.

Link to comment
Share on other sites

Hi, Malonn! I'm thrilled to hear that I was able to help you. It helps balance my karma for all the times others have helped me out!

 

I wouldn't worry about the "water above the lowest point" problem. As far as I know, that isn't possible, because the water level is set for the entire cell. If you want to have stairs going down below the water line, you have to put the stairs in a different interior cell and let the player imagine that they are below the water level of the other cell.

 

I'm a little surprised you had to script that torch behavior. I thought torches went out when they hit water anyway, but to be honest I've never tried it. :-)

Link to comment
Share on other sites

Good, good.  Great to hear about the water.

 

Yeah, I wasn't sure what to think when I saw a torch lit when it first hit the water.  I think it has to do with dropping it from the player inventory or something.  If the torch is equipped and one walks into the water, it goes out.  But if it's a torch that has been dropped via the "Drop" script function it won't go out.  **shrug**  Ah well.  Thanks to you it doesn't matter cuz it now goes out when it's supposed to.

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.

 Share

×
×
  • Create New...