Jump to content
Sign in to follow this  
Hello18

BIS_fnc_randomPos water out and water "in"?

Recommended Posts

Hello,

_position = ["water","out"] call BIS_fnc_randomPos; pulls a position on land guessing + z of 0.

This works and keeps the spawns dry, but what if I only want to spawn in the water?

tried:

_position = ["water","in"] call BIS_fnc_randomPos; -Fail

_position = ["land","out"] call BIS_fnc_randomPos; -Fail

Searched google for BIS_fnc_randomPos, not much there... thoughts?

Thanks,

Hello18

Share this post


Link to post
Share on other sites

You may just have to write your own function, using getTerrainHeightASL and looking for negative values.

Share this post


Link to post
Share on other sites

Something like

pos = ["water",["ground"]] call BIS_fnc_randomPos;

in water but not on the ground, works.

Dont think its actually fully working properly as per the specs in the sqf, seem to get all strange results back. Been playing with it through the debug console using

0 = [] spawn {while {true} do {pos = ["water,["ground"]] call BIS_fnc_randomPos; player setposATL pos;sleep 1;}}

just on a basic preview with just the player added.

If you pass it an array for parm 0 as per the BIS_fnc_params in the script it just behaves oddly, even the working water one above i dont think is paying any attention to "water" is just defaulting to the whole map just not on ground because if you change "water" to "out" as parm 0 it still just chooses any where in the water rather than edge of the map.

Same as your example i believe this is only working because your parms are not arrays and is using default params that are

_whiteList =	[_this,0,[[] call BIS_fnc_worldArea],[[]]] call bis_fnc_param;
_blackList =	[_this,1,["water","out"],[[]]] call bis_fnc_param;
_condition =	[_this,2,{true},[{}]] call bis_fnc_param;

wholemap, ["water", "out"], {}.

wholemap but not in water or outside map area.

Anyway do at users discretion as something is not right. hope the above helps.

Edited by Larrow

Share this post


Link to post
Share on other sites

getTerrainHeightASL only returns > 0 as Above Sea Level, so a negative number will never generate and an infinite loop will be created if checking for < 0.

I agree that water ground does work but threw out all kind of off the map returns like 0,-35,9999.9999, ick.

Tried:

while {!_accepted} do

{

_position = [] call BIS_fnc_randomPos;

_test = "Land_HumanSkull_F" createVehicle (_position);

if (underwater (_test)) then

{

_accepted = true;

} else {

deleteVehicle _test;

};

};

underwater seems to allow on land or ASL as well though.

The ["water","in"] call BIS_fnc_randomPos would not even be needed if a getTerrainHeightBSL was around to test for - Z, which would allow for simple if statements to test for lets say < -10. Setting up missions in less than 10 meters of water is kind of pointless unless the plan is to have snorkel missions ;)

Will wait patiently and for now just cram an array of known underwater positions to randomly select from.

Thanks

Hello18

Share this post


Link to post
Share on other sites
if a getTerrainHeightBSL was around to test for - Z, which would allow for simple if statements to test for lets say < -10.

getPosASLW and getPos will both return negative z values.

Share this post


Link to post
Share on other sites
getPosASLW and getPos will both return negative z values.

.. if you have an object to check against. I think the idea here is to check a position for terrain height given that you already have a position.

Share this post


Link to post
Share on other sites
.. if you have an object to check against. I think the idea here is to check a position for terrain height given that you already have a position.
I understand that but how hard is it armed with that information to write your own function.
//[ POSITION, OBJECT or MARKER name] call _fnc_getWaterDepth
//returns the depth of water at the position of [position], OBJECT or "marker"
//if result is ASL then 0 is returned

_option = [_this,0,[0,0,0],[[],objNull,""],[3]] call bis_fnc_param;
_pos = [0,0,0];

switch (typename _option) do {

case ("ARRAY"): {
	_pos = _option;
	_pos set [2,0];
};
case ("OBJECT"): {
	_pos = getPosATL _option;
	_pos set [2,0];
};
case ("STRING"): {
	_pos = getMarkerPos _option;
	_pos set [2,0];
};
};

_hpad = "Land_HelipadEmpty_F" createVehicle [0,0,0];
_hpad setPosATL _pos;
_poszBSL = ((getPosASLW _hpad) select 2) * -1;
if (_poszBSL < 0) then {_poszBSL = 0;};
deleteVehicle _hpad;

_poszBSL

and test map to go with. TEST MAP

IMHO the ARMA scripting language is abstracted enough as it is, no disrespect meant to the dev's but trying to do some low level stuff with objects can be a pain in the arse. TBH i would prefer some lower level script commands then other functionality can be got through BIS functions or your own. Anyway i digress and is a conversation for another topic.

Share this post


Link to post
Share on other sites

Agreed it shouldn't have to be so complicated not sure what the harm would be in adding some more BIS functions or concat, substring and try-catch blocks.

my wish-list :)

Larrow, appreciate you taking the time to construct the function err method, but adding to the -Z dilemma is now taking an object and sending it a radius with the negative z and randomizing something well used in every map I've looked at.

_randomPos = [[[getPos Obj, 20]]] call BIS_fnc_randomPos; //as in creating a group of navalmines randomly at a 20 radius

have not tried it with getPosASLW yet though... going back to the time involved thing as Larrow pointed out, It probably shouldn't be so misconstrued that it takes even somewhat skilled programers days to find what should be a simple solution. Unless the point is to move everyone into using the editor only for mission creation.

Willing to work through this though as I believe the diver/water missions are a great add and look forward to the ability of creating them to their full extent.

Once again and probably not said enough in these boards, Thanks for your time.

Hello18

---------- Post added at 22:00 ---------- Previous post was at 21:37 ----------

After posting this I realized it could be something with createMine as this works:

diveObj = createMine ["UnderwaterMine", _position, [], 5];

and this doesnt:

_randomPos = [[[getPos diveObj, 20]]] call BIS_fnc_randomPos;

_mine = createMine ["UnderwaterMine", _randompos, [], 5];

but this does work:

_randomPos = [[[getPos diveObj, 80]]] call BIS_fnc_randomPos;

_spawnGroup = [_randomPos, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "SpecOps" >> "OI_diverTeam")] call BIS_fnc_spawnGroup;

[_spawnGroup, _position] call BIS_fnc_taskDefend;

no errors in the log so it must be either looping or generating funky output as water ground, from above.

Share this post


Link to post
Share on other sites

This what i use for my Sea life , i got it from an FSM in the Animals

i think you might not need same thing but it works and is adaptable im sure to stop fish out of water :


_ctrlDepth = getTerrainHeightASL (getPos _agent);
if ((_agent isKindOf "Fish_Base_F") || (_agent isKindOf "Turtle_F")) then {
if (_ctrlDepth > -0.5) then {
	deleteVehicle _agent
}
} else {
if (_ctrlDepth < -8.5) then {
	deleteVehicle _agent
}
};

Share this post


Link to post
Share on other sites

Thromp I'll give it a whirl, thanks

also to the try-catch just saw: Fixed: BIS_fnc_error was not working correctly, yeah

will try that as well

Share this post


Link to post
Share on other sites

Ok Hello18 heres something ive been messing around with, thought you might like 🙂

randomMapPos script.

///////////////////////////////////////////////////////////////////////////////////////////////////////
//
// [[basics],[Whitelist],[blacklist],[Elevation MIN, MAX], edge distance, Debug, limit]
//
// ["water", "land", "edge"]
//		Basics selections. "edge" is per Whitelist area. defaults to everywhere is a viable position
//
// ["MARKER NAME", OBJECT (trigger), ARRAY [[position3D], #radius]
//		White & Black lists. Supplying no Whitelists selects random position using whole map
//
// [MIN, MAX] - NUMBERS (optional)
//		Elevation range that position must be in. default -1000,1000 meters
//
// edge distance - NUMBER (optional)
//		Meters within edge of Whitelist areas to choose a position. default is 200m
//
// Debug - BOOL (optional)
//		Turns on debug markers and diag_log
//
//	limit - NUMBER (optional)
//		Number of attempts to find a position. Default 100. Use 0 to disable limit. 
//
///////////////////////////////////////////////////////////////////////////////////////////////////////
 

Does basic checks for land, water or an edge of an area.

Can have multiple Whitelists and Blacklists.

Does elevation checking.

Can use with Markers, Triggers or [Pos, Radius]. Mix up any of these within the White and Black lists.

Pictures

Basic water check

Basic land check with marker

Depth checking with a marker

Positions within a trigger with elevation checking

Multiple Whitelist triggers with elevation checking

Multiple White & Black lists with elevation checking

These pictures are all from my test map with the script in debug mode. Get it HERE. Load it up in the editor and preview, its automated just to give you some ideas of what the script can do.

Any feed back appreciated.

Hope you enjoy.

Larrow

  • Like 1

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  

×