Cheitan 33 Posted August 8, 2017 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
killzone_kid 1333 Posted August 8, 2017 7 minutes ago, Cheitan said: _u = "KICC_SNIPER" createUnit [(_x buildingPos 17), (createGroup [east, true])]; Please familiarise yourself with syntax of createUnit before using this command https://community.bistudio.com/wiki/createUnit 1 Share this post Link to post Share on other sites
Cheitan 33 Posted August 8, 2017 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
HazJ 1289 Posted August 8, 2017 This may be of use to you as well. https://community.bistudio.com/wiki/BIS_fnc_buildingPositions 1 Share this post Link to post Share on other sites
Cheitan 33 Posted August 9, 2017 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
HazJ 1289 Posted August 9, 2017 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
Cheitan 33 Posted August 9, 2017 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
Grumpy Old Man 3549 Posted August 9, 2017 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
kauppapekka 27 Posted August 9, 2017 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. 1 Share this post Link to post Share on other sites
Cheitan 33 Posted August 9, 2017 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
HazJ 1289 Posted August 9, 2017 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
Tankbuster 1747 Posted August 11, 2017 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. 1 Share this post Link to post Share on other sites