Forum Jump :

Author Message


Posts: 1
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2017-11-07 03:11        
     
JR_fnc_spawn_ai = {
_state = (_this select 0);
_side = (_this select 1);
_typelist = (_this select 2);
_spawnlist = (_this select 3);
_movelist = (_this select 4);
_list1 = (_this select 5);

_group = createGroup [_side, true];
_type = (_typelist select (floor (random (count _typelist))));
_spawn = (_spawnlist select (floor (random (count _spawnlist))));
switch (_state) do {
case 1: {
_type createUnit [getMarkerPos _spawn, _group, "_unit = this", 0.6];
};
case 2: {
_type createUnit [getMarkerPos _spawn, _group, "_unit = this", 0.6];
[_unit,1, JR_weaponlist, JR_armedai] call JR_fnc_town_rearm;
};
};
{_unit = _x} foreach units _group;
_unit domove (_movelist select (floor (random (count _movelist))));
_list1 = _list1 + [_unit];
waituntil{(!alive _unit) OR (isnull _unit)};
_list1 = _list1 - [_unit];
if(!isnull _unit) then {
sleep 360;
deleteVehicle _unit;
};
};


i call this function like this: [1, east, JR_AItype, JR_SPoint, JR_movepos, JR_ailist] call JR_fnc_spawn_ai

The function is supposed to spawn an AI make it move to a location. Then add it to an array for later use.

The spawned unit is form the specified typelist and spawn on one of the spawnpoint. I receive an error message telling me that the variable "_unit" highlighted in red isn't specified. Also the unit isn't moving to any of the move point list. I've tested the moving part separately and it's working fine.

My problem is probably obvious but i can't see it!