Jump to content
Sign in to follow this  
sowens

Detect if in water

Recommended Posts

Is there a way to detect if a vehicle is in water? I need to add an additional statement to below, but only if not in water

if (_dead) then

Share this post


Link to post
Share on other sites

Thanks PvPscene...that is one page I didnt have bookmarked.

Share this post


Link to post
Share on other sites

The surfaceIsWater command only works in the ocean, not in ponds. Is there a way of detecting when you are in any kind of water? There must be because weapons stop working in water, and it doesn't matter if it is a pond or the ocean.

Share this post


Link to post
Share on other sites

_anim = animationState _unit;
_anim = toArray _anim;
_anim resize 4;
_anim = toString _anim;
if (_anim == "aswm") then { ...bla... };

Got it somewhere from this forum and works fine for me... :)

Share this post


Link to post
Share on other sites

That's good if you are swimming, but what if you are just standing in water but not swimming? See, I'm working on a script for thirst and water and I want to be able to fill a water container while standing in a lake. Going swimming to fill the container is a quick solution to the problem, but I'm hoping to find another more realistic method of finding the water at my feet.

I tried isFlatEmpty, but the water check is for sea water, not any water. :(

Edited by Feint

Share this post


Link to post
Share on other sites

I tried finding it with nearObjects and nearEntities, but no joy. nearestObjects found the pond finally when I did it like this:

...from the Biki


_list = nearestObjects [position _caller, [], 10];

Share this post


Link to post
Share on other sites
The surfaceIsWater command only works in the ocean, not in ponds.

Quote it before Feint gives a *sigh* ;)

Share this post


Link to post
Share on other sites

lol. Ideally, surfaceIsWater would /thread. But alas, the world is not always perfect.

So there are something like 140 different pond p3ds in the game, and in the game, they all have the numbers and colon in front of the name similar to:

123456: pond_big_42_18.p3d

How do I test if the word "pond" appears in the string? I want to be able to say


_list = nearestObjects [position _caller, [], 20];
_count_ponds = 0;
{if (_x contains the word "pond") then {_count_ponds = _count_ponds + 1}} forEach _list;

I just don't know how to find a specific keyword like "pond" in a string that can vary in length from "123456: pond_big_42_18.p3d" to "12345678: pond_big_01.p3d".

  • isKindOf doesn't work. It always returns false because the ponds don't have classnames
  • typeOf also does not work
  • (_x == "specific name of p3d file") always returns false because of the numbers and colon in the string

Edited by Feint

Share this post


Link to post
Share on other sites

Oooh, looks good! I'll try this. Thanks!

EDIT: It works. Thanks a lot!

Edited by Feint

Share this post


Link to post
Share on other sites

Just a warning: I recently discovered in VBS2 that the pond object dimensions reported in game, just as the bridge span object dimensions, do not always reflect the full size of the pond/bridge. For ponds consisting of a single object, you should be fine. For large lakes composed out of multiple ponds, the inner part of the pond wasn't covered by the object dimensions reported (VBS2 map Easterneuropeangeotypical25km).

I wouldn't be surprised to see a a similar problem in Arma2.

William

Share this post


Link to post
Share on other sites

OK, good to know. Thanks. I'm not currently querying the pond dimensions. I've just set the search parameter to 25 meters and it seems to accurately find ponds as soon as I enter their shorelines. With weird shaped ponds with undulating shorelines, sometimes the pond isn't found and sometimes the land is listed as the pond, but I've handled that with "too muddy" sideChat when you don't find it. So for half of the time that the pond water finding is inaccurate, it's well explained. Just walk along the shoreline and you'll find "less muddy" water eventually. It's a workaround, but feels like it makes sense when playing.

Share this post


Link to post
Share on other sites
... but I've handled that with "too muddy" sideChat ..... Just walk along the shoreline and you'll find "less muddy" water eventually.

lol ... cool. Nice fix with a realism element ;)

Share this post


Link to post
Share on other sites

Just a suggestion: find the pond object's top dimension related to the world and check if the player is under that height inside the pond's XY boundaries. That way you can have more accuracy with larger ponds.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×