Determining if something is beneath a placeable?

NWN1 original Aurora scripting engine.

I’m working on a module that involves locations that gradually flood. I’m using the Water, Low 4x4 placeable, but as the water rises (by creating new placeables at increasing Z coordinates and deleting the old ones) I need to know whether certain things have been ‘submerged’ – i.e., whether they’re underneath the placeable.

Not just at a lower Z coordinate, but actually underneath, because not all parts of the location have rising water.

Is there a way to determine this? Alternatively, is there a way to determine the bounding box of a placeable?

Thanks!

Umm this is extremely tricky. At a first glance I would say this is not possible. But perhaps there is a way…

First, if this is in one area, then your solution doesn’t have to be “generic” and can be coded specifically for that area. That means that you can have different triggers which will indicate that anyone in them is under water if the water is raised 5 times etc.

Other than that. I assume that this location has raise terrain and thus various floor heights, otherwise the problem doesn’t make sense. If that is so, I also assume that the water is centered in the lowest Z point of the area. If that is so as well, then with the Z value of the floor in the placeable position + some offset that you need to figure by trial and error for the water placeable Z difference from 0.0 and placeable water surface, you can simply use this difference and then add Z diff you are using to raise placeable to compare it with Z location of the player. Then if the difference of player position is higher than the value calculated above by X value the player is under water. Or creature/placeable, but the problem here is that various races and especially monsters has various Z size and there is no function that would return it. So again - I recommend to hand enter values for monsters used in the given area, and player races that are playable in your module. Figuring them out via trial and error…

Awful lot of work if you want to be really precise.

1 Like

It’s not just slopes and terrain heights; there’s also the issue of doors being opened/closed.

I have Z heights already recorded for a lot of critters, races, familiars, &c., encoded in a GetCreatureHeight-ish function, and likewise heights for a lot of placeables that’d be affected (flames, braziers, torches, &c.). Adding another critter is simply a matter of placing it, setting its Z to 0.0f, and adjusting a water pane until it covers the breathing orifice. Then I know how high the water needs to be before it’ll start drowning.

It’s not confined to a single area, and is actually realised as a set of data-driven functions and custom placeables. Dealing with the Z coordinate is simple – determining the XY bounding box size and placement of the overhead placeable is the tricky part.

If I special-case it to the water placeables, then I can probably hack something up from the position and facing of the water pane, since I know its XY dimensions. But developing a more general solution for any placeable would be the eventual goal.

Thanks!

Could you determine the data in the Toolset, and store it as a local on the placeables/creatures, then retrieve it when needed?

Except how to determine it even in the toolset?

By placing an object on the visual edge of the placeable, recording its position. The X in Pennants & Signs is quite useful for this, I find.

1 Like