Jump to content
Sign in to follow this  
daza

How do i use exact unit coordinates when creating a unit?

Recommended Posts

In a small town in utes ive setup a group of russians set to ambush anyone who walks through town. I saved the mission and using the mission.sqm file, i want to be able to grab the position coordinates of each unit.

Then create a script to create all those units in their unique positions within the game. (Its for a training map).

This is what ive come up so far,

_grp = creategroup east;

posmark1=[3492.5684,33.443855,4517.2529]

posmark2=[3372.3352,16.982912,4395.9561]

unit1= "RU_Soldier_MG" createunit [getpos posmark1, _grp];

unit2= "RU_Soldier_Marskman" createunit [getpos posmark2, _grp];

But it doesnt work.

I tried

_grp = creategroup east;

posmark1=[3492.5684,33.443855,4517.2529]

posmark2=[3372.3352,16.982912,4395.9561]

unit1= "RU_Soldier_MG" createunit [position posmark1, _grp];

unit2= "RU_Soldier_Marskman" createunit [position posmark2, _grp];

Does work either.

How can i use the exact coordinates for units properly?

Thanks

Daza

Share this post


Link to post
Share on other sites
Try to setPos the unit after creating it?

Thanks for your reply Deadfast.

_grp = creategroup east;

posmark1=[3492.5684,33.443855,4517.2529]

posmark2=[3372.3352,16.982912,4395.9561]

unit1= "RU_Soldier_MG" createunit [position posmark1, _grp];

unit2= "RU_Soldier_Marskman" createunit [position posmark2, _grp];

unit1 setpos [posmark1];

unit2 setpos [posmark2];

This didnt work either.

Any other ideas?

Thanks

Share this post


Link to post
Share on other sites

In mission.sqm position format is [X,Z,Y].

In a script you need [X,Y,Z].

Also posmark* already is a position, so you don't need the position / getPos command.

It should be:

_grp = creategroup east;

posmark1=[3492.5684,4517.2529,33.443855];
posmark2=[3372.3352,4395.9561,16.982912];

"RU_Soldier_MG" createunit [posmark1, _grp];
"RU_Soldier_Marskman" createunit [posmark2, _grp];

Btw. createUnit doesn't return anything. ;)

Edited by Clayman
added missing semi-columns

Share this post


Link to post
Share on other sites

Actually yeah, looking at it again your syntax is all wrong.

First of all you're mixing SQF and SQS - SQF would error out because of the missing semi-columns on lines 3 and 4 (counting empty lines too) and with SQS semi-columns shouldn't be there.

Secondly you should consider either using local variables or putting some tag in front of the global ones (DAZA_posmark1 for example) - this would be to avoid conflicts with addons.

And thirdly your usage of the position variables is incorrect.

On lines 6 and 7 you're getting a position of a position. It may not error out but it's completely obsolete.

Lines 8 and 9 should error out for sure - you've provided only one 1 coordinate which is not even a number but an array, because this is how the game interprets it:

unit1 setpos [[3492.5684,33.443855,4517.2529]];

This would be the fixed code:

SQF (run with execVM "script.sqf"):

_grp = createGroup east;

DAZA_posmark1=[3492.5684,33.443855,4517.2529];
DAZA_posmark2=[3372.3352,16.982912,4395.9561];

DAZA_unit1= "RU_Soldier_MG" createunit [position posmark1, _grp];
DAZA_unit2= "RU_Soldier_Marskman" createunit [position posmark2, _grp];
DAZA_unit1 setPos DAZA_posmark1;
DAZA_unit2 setpos DAZA_posmark2;

SQS (run with exec "script.sqs"):

_grp = createGroup east

DAZA_posmark1=[3492.5684,33.443855,4517.2529]
DAZA_posmark2=[3372.3352,16.982912,4395.9561]

DAZA_unit1= "RU_Soldier_MG" createunit [position posmark1, _grp]
DAZA_unit2= "RU_Soldier_Marskman" createunit [position posmark2, _grp]
DAZA_unit1 setPos DAZA_posmark1
DAZA_unit2 setpos DAZA_posmark2

exit

Share this post


Link to post
Share on other sites

Yeah a couple of lines i forgot to add the ; its suppose to be .sqf file only.

Ok i tried out your code fix on my script and those two units still arent being created :(

Here is how i am calling script up. I created a flagpole and have this its init

this addaction ["Set Town Ambush", "ambushsetup.sqf"];

I created a third unit, that would get created near the flagpole (to save having to drive into Kamenyy each time.)

Shall i upload my basic mission for you guys to download and run it?

I need to get this working so i can create training missions on the fly for the clan i belong to.

(Note: i had marksman mispelt, ive corrected it.) Still no go. If i use a markers as position point it works. Just with those x,y,z coordinates put into Daza_posmark1 nothing happens.

There must be a way to make this work surely....else i will just have to place invis markers where i want each individual unit to spawn.

Thanks again for you time and help with this,

Daza

Edited by Daza
correction and update

Share this post


Link to post
Share on other sites

Have you tried looking at the premade BIS spawn functions? At least they should deal with the actual spawn issue.

Damn it seems like every day there is another spawn question. In this "ambush" situation, you could search for the script I posted in the basic spawn script thread. You could make a 100+ unit ambush situation in minutes, no markers and no fidgeting with unit creation. Its 95% done in the editor. That version is a little inflexible and buggy though, I'm releasing a much better version soon...

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  

×