Jump to content
Cheitan

Problem using building positions

Recommended Posts

Hi,

 

I'm trying to create some occupation scripts, and more specifically a script designed to fill military towers with various units. Problem, the script make units spawn on ground and not in the tower. Here is my script :

//exec: server

params["_center"];

{
	_u = "KICC_SNIPER" createUnit [(_x buildingPos 17), (createGroup [east, true])];
	_u setPosATL (_x buildingPos 17);
	_units = ["KICC_OFFICIER", "KICC_FUSILIER", "KICC_TIREUR_PRECISION", "KICC_SENTINELLE_RADIO"];
	for "_i" from 0 to 16 do
	{
		if(random 1 > 0.6) then {
			_u = (selectRandom _units) createUnit [(_x buildingPos _i), (createGroup [east, true])];
			_u setPosATL (_x buildingPos _i);
		};
	};
} forEach (_center nearObjects ["Land_Cargo_Tower_V1_F", 1000]);

On ground, all units seems to be in the right X and Y position, only Z position seems to miss the point. It's strange because I'm using the exact same syntax than in the example 1 on the Biki. What am I missing ?

 

 

EDIT : when trying to set the position of the player character, in the exact same way, through the debug console, all is working as expected : the player is placed on top of the tower. I've also tried to hint the used position to check that it's a AGL position, and it is. For example for the sniper the Z value is something like 14m. And I'm definitely using setPosATL which is supposed to use this Z value and count it above ground level. I'm a bit lost...

Share this post


Link to post
Share on other sites

Oops, just seen :

Quote

NOTE: THIS SYNTAX RETURNS NO UNIT REFERENCE!

 

That's why it's not working. The create unit command only take X and Y in account, Z value is ignored. And later, when using setPosATL on _u, it's failing because _u is not the reference I was expecting. As usual, RTFM... I should be used to that, though. Thanks @killzone_kid, always a pleasure to read your articles and your notes all over the Biki !

Share this post


Link to post
Share on other sites

Mh, I'm using the engine command. This function is way way younger than the command, but it is missing a real description. Do you know what are the advantages of it compared to the command ? Performances, maybe ?

Share this post


Link to post
Share on other sites

What command? Do you mean this one:

https://community.bistudio.com/wiki/buildingPos

This isn't the same as the function I linked.

Quote

Do you know what are the advantages of it compared to the command ? Performances, maybe ?

I could be wrong but, from what I have been told... Engine commands are faster than functions. For example:

https://community.bistudio.com/wiki/BIS_fnc_selectRandom

vs

https://community.bistudio.com/wiki/selectRandom

I personally use the command rather than the function.

Again, I'm not 100% sure on this.

Share this post


Link to post
Share on other sites

That's what I think either. This function is really missing a description explaining what can be its goal, compared to buildingPos. Using buildingPos -1 will return an array containing all positions in the given building, that seems to be exactly what the function do, but maybe slower than the command. Mh, strange.

Share this post


Link to post
Share on other sites
9 minutes ago, Cheitan said:

That's what I think either. This function is really missing a description explaining what can be its goal, compared to buildingPos. Using buildingPos -1 will return an array containing all positions in the given building, that seems to be exactly what the function do, but maybe slower than the command. Mh, strange.

Both the command and the function do exactly as described, both return an ARRAY *hint hint* containing all building positions.

Nothing strange about that.

 

Cheers

Share this post


Link to post
Share on other sites

The "redundant" functions were used to do the jobs that now have been incorporated to some commands. So I'd say better to just use the commands as usually they are faster and "cleaner" looking.

BIS_fnc_buildingPositions: Introduced_with_Arma_3_version_1.00

buildingPos: Since Arma 3 v.155.133934 if index -1 is supplied, the command will return array with all available positions.

  • Like 1

Share this post


Link to post
Share on other sites
20 minutes ago, Grumpy Old Man said:

Both the command and the function do exactly as described, both return an ARRAY *hint hint* containing all building positions.

Nothing strange about that.

 

Cheers

What seemed strange to me was the fact that the function was able to do, in the better case, the same work than the command but slower. But @kauppapekka seems to be right :

 

10 minutes ago, kauppapekka said:

The "redundant" functions were used to do the jobs that now have been incorporated to some commands. So I'd say better to just use the commands as usually they are faster and "cleaner" looking.

BIS_fnc_buildingPositions: Introduced_with_Arma_3_version_1.00

buildingPos: Since Arma 3 v.155.133934 if index -1 is supplied, the command will return array with all available positions.

Considering this second annotation, I think we should now use the engine solution instead of the function.

 

Thanks for your replies !

Share this post


Link to post
Share on other sites
18 minutes ago, kauppapekka said:

The "redundant" functions were used to do the jobs that now have been incorporated to some commands. So I'd say better to just use the commands as usually they are faster and "cleaner" looking.

BIS_fnc_buildingPositions: Introduced_with_Arma_3_version_1.00

buildingPos: Since Arma 3 v.155.133934 if index -1 is supplied, the command will return array with all available positions.

Ah, my bad. Sorry. I wasn't aware of that, didn't know it could return all available positions in one go when -1 is supplied. Not used this for years ha. Hence not knowing about the change with the v1.55 update.Thanks! (:

Share this post


Link to post
Share on other sites

I missed the new command too - was using the function version yesterday!

 

Command version is rather quicker - on a building with 8 positions, performance test result for the function is 0.0108. The command version is 0.0025. So, about 4 times faster.

  • 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

×