Jump to content
Sign in to follow this  
dale0404

call BIS_fnc_spawnVehicle;

Recommended Posts

Gents, what am I doing wrong please?

this is the code in the trigger:

[(getpos troops1_1_7), BMP3,5] call BIS_fnc_spawnVehicle;

Obviously I am trying to spawn 5 BMP3s once the trigger has activated.

Ta

Dale

Share this post


Link to post
Share on other sites

The parameters for the call are different:

_this select 0: desired position (Array).

_this select 1: desired azimuth (Number).

_this select 2: type of the vehicle (String, in your case "BMP3").

_this select 3: side or existing group (Side or Group).

So if you want 5 vehicles you have to call the function five times.

for "_i" from 1 to 5 do {
   [(getpos troops1_1_7), random 360, "BMP3", east] call BIS_fnc_spawnVehicle;
};

If all vehicles should be in one group:

_grp = createGroup _side;
for "_i" from 1 to 5 do {
   [(getpos troops1_1_7), random 360, "BMP3", _grp] call BIS_fnc_spawnVehicle;
};

Xeno

Share this post


Link to post
Share on other sites

Brilliant, ty

Please dont think I am being cheeky here by asking this because I am not but,

Is there a way to spawn random vehicles and then get them to patrol? I have asked this type of question in the thread called "UPS troubles".

Thanks in advance.

Dale

Share this post


Link to post
Share on other sites

_vehicle_types = ["BMP3","BTR90","T72_RU","T90","GAZ_Vodnik","GAZ_Vodnik_HMG"];
_max_dist_between_waypoints = 50;

for "_i" from 1 to 5 do {
   _vec_type = floor (random count _vehicle_types);
   _dgrp = createGroup east;
   [(getpos troops1_1_7), random 360, _vehicle_types select _vec_type, _dgrp] call BIS_fnc_spawnVehicle;
   [_dgrp, (getpos troops1_1_7), _max_dist_between_waypoints] call BIS_fnc_taskPatrol;
};

This should create five groups with random vehicles that will patrol independent from each other.

The following will create one group with a randomly chosen vehicle type:

_vehicle_types = ["BMP3","BTR90","T72_RU","T90","GAZ_Vodnik","GAZ_Vodnik_HMG"];
_max_dist_between_waypoints = 50;

_dgrp = createGroup east;
_vec_type = floor (random count _vehicle_types);

for "_i" from 1 to 5 do {
   [(getpos troops1_1_7), random 360, _vehicle_types select _vec_type, _dgrp] call BIS_fnc_spawnVehicle;
};

[_dgrp, (getpos troops1_1_7), _max_dist_between_waypoints] call BIS_fnc_taskPatrol;

Xeno

Edited by Xeno
A fix

Share this post


Link to post
Share on other sites

Thankyou, 1 final question I promise,

How do I do the same for Infantry? I can create Infantry using the spawngroup command (I spawn 30 infantry but obviously that number can change dependant on what I want. The problem is they just stay there. How do I add the taskpatrol command for the infantry?

Code:

[(getpos troops1_1_7),east,30] call bis_fnc_spawngroup;

Cheers

Dale

Share this post


Link to post
Share on other sites

bis_fnc_spawngroup returns the newly created group.

So you can get the group with:

_dgrp = [(getpos troops1_1_7),east,30] call bis_fnc_spawngroup;

Xeno

Share this post


Link to post
Share on other sites

_dgrp = [(getpos troops1_1_7),east,30] call bis_fnc_spawngroup;
[_dgrp, (getpos troops1_1_7),east,30] call BIS_fnc_taskPatrol;

I added that to the end but the infantry is standing still, what am I doing wrong please?

Share this post


Link to post
Share on other sites
_dgrp = [(getpos troops1_1_7),east,30] call bis_fnc_spawngroup;
[_dgrp, (getpos troops1_1_7),east,30] call BIS_fnc_taskPatrol;

Remove east, from fnc_taskPatrol, it doesn't have the same parameters as fnc_spawngroup.

_this select 0: the group to which to assign the waypoints (Group)

_this select 1: the position on which to base the patrol (Array)

_this select 2: the maximum distance between waypoints (Number)

_this select 3: (optional) blacklist of areas (Array)

Xeno

Share this post


Link to post
Share on other sites

Sorry xeno, I know I am being a pain in the arse but the infantry are still not moving about mate.

Here is what is in the init field of the trigger in its entirety:

_vehicle_types = ["BMP3","BTR90","T72_RU","T90","GAZ_Vodnik","GAZ_Vodnik_HMG"];  _max_dist_between_waypoints = 50;
for "_i" from 1 to 5 do {      _vec_type = floor (random count _vehicle_types); 
_dgrp = createGroup east;      [(getpos troops1_1_7), random 360, _vehicle_types select _vec_type, _dgrp] call BIS_fnc_spawnVehicle; 
[_dgrp, (getpos troops1_1_7), _max_dist_between_waypoints] call BIS_fnc_taskPatrol;  };
_dgrp = [(getpos troops1_1_7),east,30] call bis_fnc_spawngroup;[(getpos troops1_1_7),200] call BIS_fnc_taskPatrol;

I put in the 200 at the end for the distance between the waypoints for the infantry but still no luck.

Share this post


Link to post
Share on other sites

I can do that mate but I want to make sure everything is working, its easier for me to edit in game without Alt-tabbing all the time thats all.

Share this post


Link to post
Share on other sites
I can do that mate but I want to make sure everything is working, its easier for me to edit in game without Alt-tabbing all the time thats all.

Yes, please use a script.

To get rid of Alt-tabbing simply start arma2.exe with the -window parameter, shortcut should look like this:

"C:\Program Files\Bohemia Interactive\ArmA 2\arma2.exe" -window

I never start A2 fullscreen for editing, windowed makes editing much easier :)

Xeno

Share this post


Link to post
Share on other sites

Ok, cool but would using a script get rid of the infantry not moving?

Share this post


Link to post
Share on other sites

At least it works fine here. But I have no idea if it will solve your problem :)

Xeno

Share this post


Link to post
Share on other sites

Didn't get an answer in the other thread, so I'll be cheeky and try here aswell.

is BIS_fnc_spawnGroup only able to provide friendly troops? I can only get it to spawn friendlies, and if I call it to spawn enemies, nothing appears.

Share this post


Link to post
Share on other sites
Didn't get an answer in the other thread, so I'll be cheeky and try here aswell.

is BIS_fnc_spawnGroup only able to provide friendly troops? I can only get it to spawn friendlies, and if I call it to spawn enemies, nothing appears.

That can happen if you haven't placed an enemy unit or haven't created a center for the enemy side.

Simply place one single enemy AI soldier somewhere on the map (easiest way).

Xeno

Share this post


Link to post
Share on other sites
Didn't get an answer in the other thread, so I'll be cheeky and try here aswell.

is BIS_fnc_spawnGroup only able to provide friendly troops? I can only get it to spawn friendlies, and if I call it to spawn enemies, nothing appears.

Are there other enemies on the board already? If not, you'll need to create and HQ or "Center" for them. Either by placing a single enemy anywhere on the board, or though the createCenter command.

Share this post


Link to post
Share on other sites

Thanks for the suggestion guys, placed an RU unit on the map, and everything worked as expected. I was being all clever trying to work stuff out on an empty test map ;)

Share this post


Link to post
Share on other sites

You can even set that unit to Probability of Presense 0%, so he won't even show up but still counts.

Share this post


Link to post
Share on other sites

_dgrp = [(getpos troops1_1_7),east,30] call bis_fnc_spawngroup;

Xeno

This example allowed to spawn randomly count of units that partol.

_units = 2 + Random 10;
_grp = [(getpos rupos),east,_units] call bis_fnc_spawngroup;
[_grp, (getMarkerPos "posvod"), 250] call BIS_fnc_taskPatrol;

Also this example is more randomly in select vehicle types. The group takes now randomly vehicles from the _vehicle_types list.

_vehicle_types = ["BMP3","BTR90","T72_RU","T90","GAZ_Vodnik","GAZ_Vodnik_HMG"];
_max_dist_between_waypoints = 1000;

_dgrp = createGroup east;
_vec_type = floor (random count _vehicle_types);

for "_i" from 1 to 5 do {
   [(getpos troops1_1_7), random 360, _vehicle_types [b][color="Red"]select random[/color][/b] _vec_type, _dgrp] call BIS_fnc_spawnVehicle;
};

[_dgrp, (getpos troops1_1_7), _max_dist_between_waypoints] call BIS_fnc_taskPatrol;

Edited by Imutep

Share this post


Link to post
Share on other sites

I would like to use these scripts but I get nothing created in a trigger or in a scrip.

I can create units the laborious way of creating each unit but when I use "call bis_fnc" I get nothing, do I need something enabled to use it?

If anyone has a working demo I would appreciate to see it.

Cheers

Edited by december

Share this post


Link to post
Share on other sites

Place the functions module somewhere on the map in the editor.

Using the above code in a trigger doesn't work as it uses local variables (the ones starting with _),

But...

if you surround it with call {} it will also work in a trigger On Act. field:

Looks like this:

call {
_vehicle_types = ["BMP3","BTR90","T72_RU","T90","GAZ_Vodnik","GAZ_Vodnik_HMG"];
_max_dist_between_waypoints = 1000;

_dgrp = createGroup east;
_vec_type = floor (random count _vehicle_types);

for "_i" from 1 to 5 do {
   [(getpos troops1_1_7), random 360, _vehicle_types select _vec_type, _dgrp] call BIS_fnc_spawnVehicle;
};

[_dgrp, (getpos troops1_1_7), _max_dist_between_waypoints] call BIS_fnc_taskPatrol;
}

@Imutep

Using random on an allready randomly chosen number isn't a good idea :)

Xeno

Share this post


Link to post
Share on other sites
@Imutep

Using random on an allready randomly chosen number isn't a good idea :)

Xeno

Sorry, my scripting knowledge is limited. I only tested your example and it works fine so far. But it spawns always 1-5 vehicles with the same class. (3 BMPs or 4 T90...) I remember the command select random and tested it. Now it spawns 1-5 vehicles with different classes. ( 1 BMP3 and 2 T90, or 1 T90 with 1 BRDM and 1 BMP3)

No good idea? :)

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  

×