Jump to content
Sign in to follow this  
stuguy

createvehicle & setpos question

Recommended Posts

My :

_this = createVehicle ["UAZ_AGS30_CDF", [7284.123, 7777.4097], [], 0, "IN_FORMATION"];

Works fine. But I am beyond the point where I want to use numeric notation of where I want to place my objects. I know how to spawn units at trigger positions. Example:

pos = t1; 
grp = GUE_GRP_1;
_unit1 = "GUE_Soldier_CO" createUnit [position pos, grp, "grp = This",0.5,"Sergeant"];

I am using a template to load units, and I place a trigger down on the map and name the trigger t1. In the init field, I write the above. The unit is actually in a script file, and I execVM the script file with the above variables and he spawns. I also have a vehicle in the script file, but the createvehicle will not work with these parameters:

_vehicle1 = "Ural_ZU23_Gue" createVehicle [position pos]

I read you have to setPos the item, but I do not know the syntax to combine createvehicle and setpos. Can anyone help me out? I'm trying to get the guy on a trigger named "t1"

Share this post


Link to post
Share on other sites

Example from Arma1 Domination (executed only on a medics machine):

_dir_to_set = getdir player - 180; //opening facing player
d_medtent = player modeltoworld [0,5,0]; //get some position
medic_tent = "Mash" createvehicle d_medtent;
medic_tent setdir _dir_to_set;
medic_tent setPos [position medic_tent select 0, position medic_tent select 1, 0];

Although d_medtent might be a perfect 3D location that snaps to ground, it is adviced to 're-snap' it using the x and y positions (select) and a zero for z.

Share this post


Link to post
Share on other sites
Example from Arma1 Domination (executed only on a medics machine):

_dir_to_set = getdir player - 180; //opening facing player
d_medtent = player modeltoworld [0,5,0]; //get some position
medic_tent = "Mash" createvehicle d_medtent;
medic_tent setdir _dir_to_set;
medic_tent setPos [position medic_tent select 0, position medic_tent select 1, 0];

Although d_medtent might be a perfect 3D location that snaps to ground, it is adviced to 're-snap' it using the x and y positions (select) and a zero for z.

this is easier for what im trying to do.

_vehicle1 = createVehicle ["Ural_ZU23_Gue", [(getpos pos select 0), (getpos pos select 1), 0],[], 0,"IN_FORMATION"];

thanks tho

EDIT: \\\\\\\\

For those looking at this and sayin...whaa??? _vehicle1 is what i named my truck, it equals the create vehicle command. all that Getpos stuff, it's telling the truck to be put at X first, left to right, then the second is Y, up and down on the map grid. The number at the end of the getpos series is the altitude, 0 for sealevel or ground. The last 0 is azimuth, unit rotation. now, where am I sending this truck you ask? I am sending it to variable pos. This truck is in a template script. I made a trigger that calls for my script file with the this = execVM "scriptname.sqf". But before I call the script file, I want the variables for my template to be declared so my truck is unique, instead of a generic template. so to make pos mean something, in the trigger activation before the call for the script launch, add the line pos = triggername. The trigger name being what you name your trigger in the editor. You can use this to spawn trucks or objects. To spawn enemies, check this template out:

//CREATE FACTION
_this = createCenter resistance;
//_this = createCenter west;
//_this = createCenter east;
//_this = createCenter civilian;

//SET FRIEND 0 is hostile, 1 is ally, nothing is default of 1
_this setFriend [west, 0];
//_this setFriend [east, 0];
//_this setFriend [civilian, 0];
//_this setFriend [resistance

//CREATE GENERIC GROUP
grp = createGroup resistance;

//CREATE VEHICLE
//_vehicle1 = createVehicle ["Ural_ZU23_Gue", [(getpos pos select 0), (getpos pos select 1), 0],[], 0,"IN_FORMATION"];


//CREATE LEADER
_unit1 = "GUE_Soldier_CO" createUnit [position pos, grp, "grp=This",0.5,"Sergeant"];
// VEHICLE TO GROUP ADDITION STARTS HERE AND CONTINUES AFTER EACH UNIT CREATED
//grp addvehicle _vehicle1;
//_unit1 moveinDriver _vehicle1;

//CREATE SOLDIER A
_unit2 = "GUE_Soldier_Medic" createUnit [position pos, grp, "",0.4,"Corporal"];
//_unit2 moveinCargo _vehicle1;
//CREATE SOLDIER B 
_unit3 = "GUE_Soldier_GL" createUnit [position pos, grp, "",0.4,"Private"];
//_unit3 moveinCargo _vehicle1;
//CREATE SOLDIER C
_unit4 = "GUE_Soldier_3" createUnit [position pos, grp, "",0.4,"Private"];
//_unit4 moveinCargo _vehicle1;
//CREATE SOLDIER D
_unit5 = "GUE_Soldier_2" createUnit [position pos, grp, "",0.4,"Private"];
//_unit5 moveinGunner _vehicle1;
//CREATE SOLDIER E
_unit6 = "GUE_Soldier_AT" createUnit [position pos, grp, "",0.4,"Private"];
//_unit6 moveinCargo _vehicle1;

//END

type this in the activation field of your trigger, make sure you name the trigger yourtriggername...or change the damn name to whatever you want, so long as it is on both entries.

grp = yourGroupname; pos = yourtriggername; this = execVM "thisscriptname.sqf";

I commented a lot of my script out for the 6 man guerilla team and the truck. It's broken, I can get the truck and the leader to spawn, but I broke the sequence of getting him in the truck and spawning the rest of his buddies.

Edited by stuguy
explanation needed

Share this post


Link to post
Share on other sites
_vehicle1 = "Ural_ZU23_Gue" createVehicle [position pos]

I doubt this would work.

Should look like this:

[code]_vehicle1 = "Ural_ZU23_Gue" createVehicle position pos

or:

[code]_vehicle1 = "Ural_ZU23_Gue" createVehicle [position pos select 0, position pos select 1, position pos select 2]

About that "pos" variable:

Why use "position pos" every time, instead of just saving the position in a variable called pos.

Activiation:

"trg = this; pos = position trg"

that should be easier to handle and it wouldnt matter how you name the trigger.

In general, it looks like a good start but there is a lot of cleaning up to do with your script. Oh and don't forget to use the [b]assignAsCargo[/b] command too, when you use [b]moveInCargo[/b], otherwise the AI won't know they're in that truck. xD

Share this post


Link to post
Share on other sites
_vehicle1 = "Ural_ZU23_Gue" createVehicle [position pos]
I doubt this would work.

Should look like this:
[code]_vehicle1 = "Ural_ZU23_Gue" createVehicle position pos

or:

_vehicle1 = "Ural_ZU23_Gue" createVehicle [position pos select 0, position pos select 1, position pos select 2]

About that "pos" variable:

Why use "position pos" every time, instead of just saving the position in a variable called pos.

Activiation:

"trg = this; pos = position trg"

that should be easier to handle and it wouldnt matter how you name the trigger.

In general, it looks like a good start but there is a lot of cleaning up to do with your script. Oh and don't forget to use the assignAsCargo command too, when you use moveInCargo, otherwise the AI won't know they're in that truck. xD

that's exactly what I was doing. I had a template script and the trigger would only declare my unique variables, such and group and position. The units all spawn at the trigger with ease.

Edited by stuguy

Share this post


Link to post
Share on other sites

another set position question....

As stated before, I am using working templates to generate units and vehicles at triggers, only stating the variables to identify the group and position to make it happen. Gr8 success!

Now on to bigger things:

I wanna create objects in the same manor. But not just create them like I do vehicles. I want to spawn them a set distance, height, and azimuth from a marker i also put in my script as a reference. For example. I create and enemy camp template and reference their position to my marker for enemy camp, and i place these files in a script. My trigger will thus launch the script with the variable

pos = triggername

before I

this = execVM "script.sqf"

The marker will be the only thing that has "pos" in it for it's position reference. So it will naturally assume the triggername I specified before I launched my script. So My marker loads at the trigger. I know how to do this, but I do not know how to make items appear a set distance X,Y,Z from the marker "X" in my script. Can anyone help me with this?

Marker:

_this = createMarker ["markerx", [(getpos pos select 0), (getpos pos select 1), 0]];

Object: Taking a WAG here...

_object1 = "objectx" createVehicle [(getpos markerx [setpos +/-# select 0]), (getpos markerx [setpos +/-# select 1]), 0];

Edited by stuguy
more commands for example

Share this post


Link to post
Share on other sites

did you know you can pass variables to an script ?

instead of using

pos = triggername
this = execVM "script.sqf"

you could use

nul = [triggername] execVM "script.sqf"

and in the script:

_pos = _this select 0

Can you clarify how those objects should be placed ? In a circle at a fixed distance around the trigger ? Randomly ? In a square ? Either way, for all this you need no special scripting. All you need is some maths and maybe the random command.

f.e.:

_size = 100;
_object1 = "objectx" createVehicle [0,0,0];
_object1 setpos [(getpos markerx select 0) - _size / 2 + random _size,(getpos markerx select 1) - _size / 2 + random _size,0];

this would place the object randomly in a square with a sidelength of 100meters at the marker.

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  

×