Jump to content
Sign in to follow this  
MuffEater

several consequences with an if-clause

Recommended Posts

hi,

I've been working for a while on a little mission, where we need an extraction at the end.

Since the other guys with us are AI, I need to tell them to get in the chopper when it's arrived.

I made something like this:

if (alive unit_0) then {

_grp0 = group unit_0;

_wp0 = _grp0 addWaypoint [position heli1, 0];

_wp0 setWaypointType "GETIN";

_wp0 setWaypointBehaviour "CARELESS";

_wp0 setWaypointCombatMode "GREEN";

_wp0 setWaypointSpeed "FULL";

_grp0 setCurrentWaypoint [_grp0, _wp0];

}

else {exitWith{}};

};

and copy and paste it for the others AI (eventually not without changing all the "0" in "1", "2",etc...).

The point is that it doesn't work, and I think I may commit suicid soon if I keep on going like this....:pet13:

So, if anyone has an idea why it doesn't work (I mean they just stay here and carry on shooting on the bad Zombies), he (or she, no sexism) might become my god(dess).:notworthy:

Thank you by advance.

Share this post


Link to post
Share on other sites

What I can quickly notice...

1) remove the the "else" and "exitWith"..."exitWith" is used to break the innermost loop (for, while, forEach loops). So just if(...) then { ...};

2) Line "_grp0 setCurrentWaypoint [_grp0, _wp0];"

should be "_grp0 setCurrentWaypoint _wp0;

EDIT: Exactly where did you put this? Note that a waypoint is always added for the whole group, so it needs to be added only once and then all the group members have that waypoint.

Edited by Aqu

Share this post


Link to post
Share on other sites

1)ok I'll do it, and I'll tell you tomorrow (it's about 1 a.m. here...)

2)same

3)I put it in a script which make the heli come to a precise position (ok), make it land (ok), set a new objective to the player (ok) and set those waypoints to the AI's (not ok).

thx again

Share this post


Link to post
Share on other sites

Hi, here I paste a function I create for UPSMON.

Only u need is to assign any soldier to a position of the vehicle, the function below has three parameters

_grpid = _this select 0;

_unitsin = _this select 1;

_vehicle = _this select 2;

_grpid: dont mind for u, in UPSMON is for identifying the group in the vehicle

_unitsin: array of units to get in the vehicle

_vehicle: vehicle to get in.

//Funcion que mete la tropa en el vehiculo
MON_UnitsGetIn = {
	private["_grpid","_vehicle","_npc","_driver","_gunner", "_unitsin", "_units" , "_Commandercount","_Drivercount","_Gunnercount","_cargo",
			"_Cargocount","_emptypositions","_Commander","_vehgrpid","_cargo"];	

	_grpid = _this select 0;
	_unitsin = _this select 1;
	_vehicle = _this select 2;

	_units = _unitsin;				
	_driver = objnull;
	_gunner = objnull;	
	_Commander	= objnull;
	_Cargocount = 0;
	_Gunnercount = 0;
	_Commandercount = 0;
	_Drivercount = 0;
	_cargo = [];

	_Cargocount = (_vehicle) emptyPositions "Cargo";
	_Gunnercount = (_vehicle) emptyPositions "Gunner"; 
	_Commandercount = (_vehicle) emptyPositions "Commander"; 
	_Drivercount = (_vehicle) emptyPositions "Driver"; 	

	_emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount;		

	//Obtenemos el identificador del vehiculo
	_vehgrpid = _vehicle getvariable ("your_grpid");
	_cargo = _vehicle getvariable ("your_cargo");
	if ( isNil("_vehgrpid") ) then {_vehgrpid = 0;};	
	if ( isNil("_cargo") ) then {_cargo = [];};			


	//Hablitamos a la IA para entrar en el vehiculo		
	{		
		unassignVehicle _x;			
		_x spawn MON_Allowgetin;						
	}foreach _units;		

	{		
		if ( _x == leader _x && _Cargocount > 0 ) then
		{
			_x assignAsCargo _vehicle;	
			_units = _units - [_x];
			[_x] orderGetIn true;	
		};
	}foreach _units;	

	//Si el vehiculo pertenece al grupo asignamos posiciones de piloto, sinó solo de carga
	if ( _vehgrpid == _grpid ) then {
		//Asignamos el conductor
		if ( _Drivercount > 0 && count (_units) > 0 ) then { 
			_driver =  _units  select 0;					
			[_driver,_vehicle,20] spawn MON_assignasdriver;				
			_units = _units - [_driver];
		};

		//Asignamos el artillero
		if ( _Gunnercount > 0 && count (_units) > 0 ) then { 						
			_gunner =  _units select 0;
			_gunner assignAsGunner _vehicle;
			_units = _units - [_gunner];
		};

		//Asignamos el comandante
		if ( _Commandercount > 0 && count (_units) > 0 ) then { 	
			_Commander =  _units select 0;		
			_Commander assignAsCommander _vehicle;
			_units = _units - [_Commander];	
		};

	};

	//Movemos el resto como carga
	{			 
		_x assignAsCargo _vehicle;	
		_units = _units - [_x];	
	} forEach _units;  


	{			 
		[_x,0] spawn MON_dostop;
		[_x] orderGetIn true;	
	} forEach _unitsin - [_driver]; 	

	_cargo = _cargo - _unitsin; //Para evitar duplicados
	_cargo = _cargo + _unitsin; //Añadimos a la carga
	_vehicle setVariable ["your_cargo", _cargo, false];				
};	

I had other functions that may be utils for u like looking for nearest vehicles, getout.. u can find it in MON_functions.sqf in UPSMON http://forums.bistudio.com/showthread.php?t=91696

Edited by Monsada

Share this post


Link to post
Share on other sites

@ aqui

It still not working but I'll try Monsada's solution when I'll get time (what isn't the case right now)

again, thx for your help guys

EDIT: Monsada, if I well understood your script, it assign the vehicle to the new group, but I only need several units to get in the cargo part of the chopper, is it possible to just remove this part ?

//Si el vehiculo pertenece al grupo asignamos posiciones de piloto, sinó solo de carga

if ( _vehgrpid == _grpid ) then {

//Asignamos el conductor

if ( _Drivercount > 0 && count (_units) > 0 ) then {

_driver = _units select 0;

[_driver,_vehicle,20] spawn MON_assignasdriver;

_units = _units - [_driver];

};

//Asignamos el artillero

if ( _Gunnercount > 0 && count (_units) > 0 ) then {

_gunner = _units select 0;

_gunner assignAsGunner _vehicle;

_units = _units - [_gunner];

};

//Asignamos el comandante

if ( _Commandercount > 0 && count (_units) > 0 ) then {

_Commander = _units select 0;

_Commander assignAsCommander _vehicle;

_units = _units - [_Commander];

};

};

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  

×