Jump to content
Sign in to follow this  
clawhammer

2 bis_fnc_spawnvehicle asks

Recommended Posts

Hi together,

i tried to spawn an attack heli with this command:

grp4 = [getMarkerPos "espawn", 180, "O_Heli_Attack_02_F", EAST] call bis_fnc_spawnvehicle;

Now i want to give him a waypoint:

_wp3 = grp4 addWaypoint [getMarkerPos "espawntarget", 0];

But nothing happens, the script look like it abort at this point? Any tipp for me?

secound ask:

grp5 = [getMarkerPos "espawn_2", 180, "O_Heli_Light_02_F", EAST] call bis_fnc_spawnvehicle;

This spawns a Transport Heli, how can i fill it with Units and make a marker to thow the guys out?

Thanks for your help!

Share this post


Link to post
Share on other sites

grp4 is an array of [VEHICLE,CREW,GROUP]

So you will need:

_wp3 = (grp4 select 2) addWaypoint [getMarkerPos "espawntarget", 0];

Share this post


Link to post
Share on other sites
grp4 is an array of [VEHICLE,CREW,GROUP]

So you will need:

_wp3 = (grp4 select 2) addWaypoint [getMarkerPos "espawntarget", 0];

Thank you very much, this works!

Now i only have to figure out how to put infantry in the transport heli and how to unload it O.o pls help!

Share this post


Link to post
Share on other sites

Create the heli with troops in it? or you mean in game spawning, mounting, riding and unloading?

Share this post


Link to post
Share on other sites
Create the heli with troops in it? or you mean in game spawning, mounting, riding and unloading?

Currently iam spawning the helip with script:

grp5 = [getMarkerPos "espawn_2", 180, "O_Heli_Light_02_F", EAST] call bis_fnc_spawnvehicle;

I spawn the infantry with this:

grp1 = createGroup east;
grp1 = [getMarkerPos "espawn", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

Now i want the infantry in the heli. The heli should get an waypoint to unload his cargo and fly away.

Share this post


Link to post
Share on other sites

This is my function i made for EOS. It fills empty seats in vehicle.

Null= [grp4] execVM "cargoFill.sqf";

//cargofill.sqf
if (!isServer) exitWith {};
private ["_cargoPool","_emptySeats","_vehicle","_debug","_grp","_grpSize"];
_vehicle=(_this select 0);
_debug=false;

_cargoPool=[];// ADD INFANTRY CLASSNAMES HERE
_grp = createGroup WEST;
_grpSize=20;// SET SIZE OF GROUP

// FILL EMPTY SEATS		
_emptySeats=_vehicle emptyPositions "cargo";
if (_debug) then {hint format ["%1",_emptySeats];};


// IF VEHICLE HAS SEATS	
	if (_emptySeats > 0) then {

// LIMIT SEATS TO FILL TO GROUP SIZE		
		if 	(_grpSize > _emptySeats) then {_grpSize = _emptySeats};					
					if (_debug) then {hint format ["Seats Filled : %1",_grpSize];};	

					for "_x" from 1 to _grpSize do {					
							_unit=_cargoPool select (floor(random(count _cargoPool)));
							_unit=_unit createUnit [GETPOS _vehicle, _grp];
							};


{_x moveincargo _vehicle}foreach units _grp;
};						

Share this post


Link to post
Share on other sites

Easy, first, I recommend to assign local variables to parts of the heli array, I mean:

_heli = grp4 select 0;
_groupheli = group _heli;

Or something like that, it will be more comfortable.

Second: to put the infantry in cargo:

{_x moveInCargo _heli} forEach units grp1;

Now with waypoints:

_wp3 = _groupheli addWaypoint [getMarkerPos "espawntarget", 0];
_wp4 = grp1 addWaypoint [getMarkerPos "espawntarget", 0];

[_groupheli, 0] setWaypointType "UNLOAD";
[grp1, 2] setWaypointType "GETOUT";

[_groupheli, 0] synchronizeWaypoint [ [grp1, 0] ];


I recommend to put via script or map an invisible helipad near "espawntarget" marker.

From this you may add another waypoint to the _heli to move from there once unloaded to anywhere of the map.

Hope this helps (been messing with this yesterday)

I also recomend you check the wiki commands regarding waypoints, is very easy to understand.

Share this post


Link to post
Share on other sites
This is my function i made for EOS. It fills empty seats in vehicle.

Null= [grp4] execVM "cargoFill.sqf";

//cargofill.sqf
if (!isServer) exitWith {};
private ["_cargoPool","_emptySeats","_vehicle","_debug","_grp","_grpSize"];
_vehicle=(_this select 0);
_debug=false;

_cargoPool=[];// ADD INFANTRY CLASSNAMES HERE
_grp = createGroup WEST;
_grpSize=20;// SET SIZE OF GROUP

// FILL EMPTY SEATS		
_emptySeats=_vehicle emptyPositions "cargo";
if (_debug) then {hint format ["%1",_emptySeats];};


// IF VEHICLE HAS SEATS	
	if (_emptySeats > 0) then {

// LIMIT SEATS TO FILL TO GROUP SIZE		
		if 	(_grpSize > _emptySeats) then {_grpSize = _emptySeats};					
					if (_debug) then {hint format ["Seats Filled : %1",_grpSize];};	

					for "_x" from 1 to _grpSize do {					
							_unit=_cargoPool select (floor(random(count _cargoPool)));
							_unit=_unit createUnit [GETPOS _vehicle, _grp];
							};


{_x moveincargo _vehicle}foreach units _grp;
};						

Thanks, but this script is a little bit too complex for me :-(

grp4 is an array of [VEHICLE,CREW,GROUP]

If grp5 select 0 is the vehicle, why i cannot give it a name and put the infantry in it?

otheli = (grp5 select 0);

grp1 = group this; {_x moveinCargo otheli} foreach units group this;

Share this post


Link to post
Share on other sites

Check my last post to know how to do it.

In other hand: I recommend to use local variables (the ones with the _) instead of global (without the _) when you are scripting.

Reason: imagine you want to use this script two times. You will be calling the same names to groups, units etc.. which will mess things up a lot

For example if you call the script two times with this:

grp1 = [getMarkerPos "espawn", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

You will créate two identical groups in the same position, but you will be only able to refer to the last one as grp1, so if, for example in the later script you put something like leader grp1 doMove position, only the leader of the last created group will move.

Edited by barbolani

Share this post


Link to post
Share on other sites
Check my last post to know how to do it.

In other hand: I recommend to use local variables (the ones with the _) instead of global (without the _) when you are scripting.

Reason: imagine you want to use this script two times. You will be calling the same names to groups, units etc.. which will mess things up a lot

For example if you call the script two times with this:

grp1 = [getMarkerPos "espawn", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

You will créate two identical groups in the same position, but you will be only able to refer to the last one as grp1, so if, for example in the later script you put something like leader grp1 doMove position, only the leader of the last created group will move.

Thank you, i got it working :)!

Here is my full script:

// =========================================================================================================
//  Spawn Script
//  Version: 1.0
//  Author: Clawhammer
// ---------------------------------------------------------------------------------------------------------
//
// Spawn Infantry Group
grp1 = createGroup east;
grp1 = [getMarkerPos "espawn", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;

_wp = grp1 addWaypoint [getMarkerPos "espawntarget", 0];

// Spawn Tank Group
grp2 = createGroup east;
grp2 = [getMarkerPos "espawn_1", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Armored" >> "OIA_TankPlatoon")] call BIS_fnc_spawnGroup;

_wp1 = grp2 addWaypoint [getMarkerPos "espawntarget", 0];

// Spawn MechTank Group
grp3 = createGroup east;
grp3 = [getMarkerPos "espawn_2", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Mechanized" >> "OIA_MechInfSquad")] call BIS_fnc_spawnGroup;

_wp2 = grp3 addWaypoint [getMarkerPos "espawntarget", 0];

// Spawn Attack Heli
grp4 = [getMarkerPos "espawn", 180, "O_Heli_Attack_02_F", EAST] call bis_fnc_spawnvehicle;

_wp3 = (grp4 select 2) addWaypoint [getMarkerPos "espawntarget_1", 0];

// Spawn Transport Heli with infantry and throw units out at waypoint
grp5 = [getMarkerPos "espawn_1", 180, "O_Heli_Light_02_F", EAST] call bis_fnc_spawnvehicle;

_heli = grp5 select 0;
_groupheli = group _heli;

{_x moveInCargo _heli} forEach units grp1;

_wp4 = (grp5 select 2) addWaypoint [getMarkerPos "espawntarget_2", 0];
_wp4 setWayPointBehaviour "CARELESS";
_wp4 setWayPointSpeed "NORMAL";
_wp4 setWayPointType "TR UNLOAD";
_wp4 setWayPointCombatMode "WHITE";
_wp4 setWaypointStatements ["true","helo land 'LAND';"];

_wp5 = (grp5 select 2) addWaypoint [getMarkerPos "espawntarget_1", 0];

This Script maybe looks a little bit confuse and without any reason because it was for testing. But it has some cool commands and maybe it will help someone else if he is looking for the same.

On the map there are some Markers needed:

espawntarget

espawntarget_1

espawntarget_2

Where the units go

espawn

espawn_1

espawn_2

Where the units spawn

But you are right, if i run my script a few times it will be a mess :D

xgilgp5q.jpg

Reason: imagine you want to use this script two times. You will be calling the same names to groups, units etc.. which will mess things up a lot

So i should use instead of grp1,grp2,grp3..... _grp1,_grp2 and so on? Or wich variables do you mean?

- - -

Additionally here are some helpfull links:

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

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

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

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

Edited by Clawhammer

Share this post


Link to post
Share on other sites

Like:

_clawHammersHeliInfoArray = [getMarkerPos "espawn", 180, "O_Heli_Attack_02_F", EAST] call bis_fnc_spawnvehicle;

_heli = _clawHammersHeliInfoArray select 0;
_crew = _clawHammersHeliInfoArray select 1;
_gruppe = _clawHammersHeliInfoArray select 2;

// code here - for example

{
   _x allowDamage false;
} forEach _crew;

_heli setDamage 1;

hint format ["damn that %1 is invincible", _gruppe];

And then you can call the script multiple times if you want at once and the variables from all the different instances of the scripts won't interfere with each other. :)

Edited by Das Attorney

Share this post


Link to post
Share on other sites
Like:

_clawHammersHeliInfoArray = [getMarkerPos "espawn", 180, "O_Heli_Attack_02_F", EAST] call bis_fnc_spawnvehicle;

_heli = _clawHammersHeliInfoArray select 0;
_crew = _clawHammersHeliInfoArray select 1;
_gruppe = _clawHammersHeliInfoArray select 2;

// code here - for example

{
   _x allowDamage false;
} forEach _crew;

_heli setDamage 1;

hint format ["damn that %1 is invincible", _gruppe];

And then you can call the script multiple times if you want at once and the variables from all the different instances of the scripts won't interfere with each other. :)

Ok, thanks for the tipp! :-)

Share this post


Link to post
Share on other sites
So i should use instead of grp1,grp2,grp3..... _grp1,_grp2 and so on? Or wich variables do you mean?

Yes, exactly

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  

×