Jump to content
Sign in to follow this  
eggbeast

creating multiple groups in a script

Recommended Posts

I've looked about but can't find any discussion on this specific issue...

In evolution I'm adding in a range of side-missions. Each one is a standalone sqf.

The Rescue Agent mission creates 4 groups:

1 Agent (1 civilian),

2 Interrogators (east 2 INS leaders),

3 Insurgents (east 8 INS troops in 4 vehicles)

4 partisans (east 12 INS armed civs) and

Now, I can get the groups above 1,2 and 4 to spawn but 3 (the insurgent militia) never does, and periodically none of them spawn or maybe just 1 and 2 spawn or just 1 - the agent - she seems to work fine lol.

here is the full script

//rendition island to carrier
_user = _this select 0;
_var = _this select 1;
_usergroup = (group _user);
_pos = [0,0,0];
_trgobj3 = objNull;
_start = "";
BIS_EVO_sobj1 = false;

_allobj = [];
_player = player;

_txtcommon = localize "STR_M04t0_5";
_txtfailhead = localize "STR_M04t2_6";
_txtpasshead = localize "STR_M04t1_9";
_txtpassbody = format["+%1 %2",_var,_txtcommon];

_MissionBriefingLong = localize "STR_M04t25_0";
_MissionBriefingHUD = localize "STR_M04t23_0";
_MissionBriefingShort = localize "STR_M04t24";

_MissionBriefingHUD2 = localize "STR_M04t26_0";
_MissionBriefingHUD3 = localize "STR_M04t29_0";

_txthmid = localize "STR_M04t27_0";
_txtbmid = localize "STR_M04t28";

_txtfailbody = localize "STR_M04t30_0";

_deletemcsard =
{
_user removeSimpleTask _obj1;
deleteVehicle _trgobj3;
deleteMarkerLocal _start;
BIS_EVO_Onmission=false;
sleep 1;
_handle = [_mcsardga] execVM "data\scripts\delete.sqf";
_handle = [_mcsardgb] execVM "data\scripts\delete.sqf";
_handle = [_mcsardgc] execVM "data\scripts\delete.sqf";
_handle = [_pilot] execVM "data\scripts\delete.sqf";
sleep 0.5;
deleteVehicle _hostage;
sleep 0.5;
deleteVehicle _heli;
sleep 0.5;
deleteVehicle _heli1;
sleep 0.5;
deleteVehicle _heli2;
sleep 0.5;
deleteVehicle _heli3;
sleep 0.5;
deleteVehicle _heli4;
sleep 0.5;
deleteVehicle _heli5;
sleep 0.5;
deleteVehicle _heli6;
};

_Faild = 
{
["#FF0000",_txtfailhead,_txtfailbody] call BIS_EVO_Message;
hint "Rescue Agent: Mission Failed\nAgent dead";
[] call _deletemcsard;
};

[West,"HQ"] SideChat localize "STR_M04t64";

//mrnd 27 position[]={13659.114,43.612572,3001.083}; skalisty island
//mrnd28 position[]={11257.404,290.61249,4290.7964}; rog
//mrx3 position[]={11164.056,24.606155,2496.3931}; drakon lighthouse
//mrx4 position[]={11675.623,1.9162652,3181.3203}; swamp

//mrnd21 position[]={10424.39,6,2582.4426}; 
//mrnd25 position[]={13414.312,5.6582017,6246.6104};
//mrnd28 position[]={11257.404,290.61249,4290.7964};
//mrx7 position[]={8866.6211,219.56129,2905.3794};
//mrx9 position[]={13231.934,3.9422619,5436.5508};

//	_allobj = ["mrnd27","mrnd28","mrx3","mrx4"];

_allobj = ["mrnd27"];

_max = count _allobj;
_r = round random (_max - 1);
_rand =  _allobj select _r;
_pos = getMarkerPos _rand;

_rndx = random 200;
_rndy = random 200;
_rndbx = random 200;
_rndby = random 200;
_rndcx = random 200;
_rndcy = random 200;
_rnddx = random 200;
_rnddy = random 200;

_pos1 = [(_pos select 0)-50,(_pos select 1)-50,0];
_pos2 = [(_pos select 0)-100 +_rndbx,(_pos select 1)-100+_rndby,0];
_pos3 = [(_pos select 0)-100 +_rndcx,(_pos select 1)-100+_rndcy,0];
_pos4 = [(_pos select 0)-100 +_rndx,(_pos select 1)-100+_rndy,0];
_pos5 = [(_pos select 0)-100 +_rnddx,(_pos select 1)-100+_rnddy,0];

_obj1 = _user createSimpleTask ["obj1"];
_obj1 setSimpleTaskDescription [_MissionBriefingLong,_MissionBriefingShort,_MissionBriefingHUD];
_obj1 setSimpleTaskDestination _pos;
_obj1 settaskstate "Created";
_user setCurrentTask _obj1;

[1800] execVM "data\scripts\timer.sqf";

//map
_mapview = [_pos,1] execVM "data\scripts\mismap.sqf";

waitUntil {_user distance _pos < 1500 or not BIS_EVO_Onmission};
//if (_usergroup != (group _user) or not BIS_EVO_Onmission) exitwith {[] call _Faild};
if (not BIS_EVO_Onmission) exitwith {[] call _Faild};

_pilot = createGroup (civilian);//agent
sleep 1;
//AGENT

_allunitsA = ["RU_Hooker4","RU_Hooker3","RU_Hooker2","RU_Hooker5","RU_Hooker1"];
_max = count _allunitsA;

_hostage = _pilot createUnit [_allunitsA select (round random (_max - 1)), _pos1, [], 10, "NONE"];Sleep BIS_EVO_GlobalSleep;

{
_x disableAI "MOVE";
_x allowfleeing 0;
_x setBehaviour "Careless";
removeallweapons _x;
_x setCaptive true;
commandStop _x;
_x addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}]
} forEach units _pilot;

sleep 1.0;
hint format["Agent count %1",(count units _pilot)];

{
_x switchMove "AmovPercMstpSsurWnonDnon";
} forEach units _pilot;

//GUARDS

_mcsardga = createGroup (east);//2 commanders
sleep 2;

_allunitsB = ["Ins_Lopotev","Ins_Commander","Ins_Bardak"];
_max = count _allunitsB;

_allunitsB select (round random (_max - 1)) createUnit [_pos1, _mcsardga];Sleep BIS_EVO_GlobalSleep;
_allunitsB select (round random (_max - 1)) createUnit [_pos1, _mcsardga];Sleep BIS_EVO_GlobalSleep;	

{_x addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}]} forEach (units _mcsardga);

hint format["mcsardga count %1",(count units _mcsardga)];
sleep 2;

//VEHICLES

_allvecA = ["BMP2_Ambul_INS","Offroad_DSHKM_INS","Ural_ZU23_INS"];
_allvecB = ["UAZ_AGS30_RU","UAZ_SPG9_INS","UAZ_MG_INS"];
_allvecC = ["T72_INS","T90","BMP3"];
_allvecD = ["BTR90","BRDM2_INS","Mi17_Ins","BMP2_INS"];

_maxA = count _allvecA;
_maxB = count _allvecB;
_maxC = count _allvecC;
_maxD = count _allvecD;

_heli = createVehicle [(_allvecA select round random (_maxA - 1)), _pos2, [], 10, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli] spawn {[_this select 0] call BIS_EVO_idelSVEC};
//	[_heli] call BIS_EVO_Lock;
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_heli1 = createVehicle [(_allvecB select round random (_maxB - 1)), _pos3, [], 10, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli1] spawn {[_this select 0] call BIS_EVO_idelSVEC};
//	[_heli1] call BIS_EVO_Lock;
_heli1 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_heli2 = createVehicle [(_allvecC select round random (_maxC - 1)), _pos4, [], 10, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli2] spawn {[_this select 0] call BIS_EVO_idelSVEC};
//	[_heli2] call BIS_EVO_Lock;
_heli2 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_heli3 = createVehicle [(_allvecD select round random (_maxD - 1)), _pos5, [], 10, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli3] spawn {[_this select 0] call BIS_EVO_idelSVEC};
//	[_heli3] call BIS_EVO_Lock;
_heli3 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_heli4 = createVehicle ["FlagCarrierRU", _pos1, [], 20, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli4] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli4 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_heli5 = createVehicle ["BMP2_HQ_INS_unfolded", _pos1, [], 20, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli5] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli5 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_heli6 = createVehicle ["Land_Fire_burning", _pos1, [], 10, "NONE"];
Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli6] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli6 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

// CREW INSURGENTS

sleep 2;
_mcsardgb = createGroup (east);//4 vehicles and 9 insurgent crew
sleep 2;

//_allunitsJ = ["Ins_Villager3","Ins_Woodlander3","Ins_Woodlander2","Ins_Worker2","Ins_Villager4","Ins_Woodlander1"];

_allunitsJ = ["Ins_Soldier_1","Ins_Soldier_2","Ins_Soldier_AA","Ins_Soldier_AT","Ins_Soldier_AR","Ins_Soldier_Crew","Ins_Soldier_GL","Ins_Soldier_MG","Ins_Soldier_Medic","Ins_Soldier_CO","Ins_Soldier_Pilot","Ins_Soldier_Sab","Ins_Soldier_Sapper","Ins_Soldier_Sniper"];

//_allunitsC = ["Ins_Lopotev","Ins_Commander","Ins_Bardak"];
//_max = count _allunitsC;
//	_allunitsJ = ["RU_Soldier_MG"];	
_max = (count _allunitsJ)-1;

_csardcounta = 8;
_d = 0;
while {_d <= _csardcounta} do 
{
	_unit = _mcsardgb createUnit [_allunitsJ select (round random _max), _pos, [], 6, "FORM"];
	_unit setSkill 2+(random 3);
//	{_x addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}]} forEach (units _mcsardgb);

	_unit addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
	[_unit] join _mcsardgb;
	_d = _d+1;
	sleep 1;
};

hint format["mcsardgb count %1",(count units _mcsardgb)];

(units _mcsardgb select 0) assignAsDriver _heli;
(units _mcsardgb select 0) moveInDriver _heli;
sleep 0.2;
(units _mcsardgb select 1) assignAsCargo _heli;
(units _mcsardgb select 1) moveInCargo _heli;
sleep 0.2;
(units _mcsardgb select 2) assignAsDriver _heli1;
(units _mcsardgb select 2) moveInDriver _heli1;
sleep 0.2;
(units _mcsardgb select 3) assignAsGunner _heli1;
(units _mcsardgb select 3) moveInGunner _heli1;
sleep 0.2;
(units _mcsardgb select 4) assignAsDriver _heli2;
(units _mcsardgb select 4) moveInDriver _heli2;
sleep 0.2;
(units _mcsardgb select 5) assignAsGunner _heli2;
(units _mcsardgb select 5) moveInGunner _heli2;
sleep 0.2;
(units _mcsardgb select 6) assignAsDriver _heli3;
(units _mcsardgb select 6) moveInDriver _heli3;
sleep 0.2;
(units _mcsardgb select 7) assignAsGunner _heli3;
(units _mcsardgb select 7) moveInGunner _heli3;

hint format["mcsardgb mounted %1",(count units _mcsardgb)];

//PARTISANS

_mcsardgc = createGroup (east);//12 partisans
sleep 2;

//	_allunitsK = ["RU_Soldier_Marksman","RU_Soldier_Medic"];
_allunitsK = ["Ins_Villager3","Ins_Woodlander3","Ins_Woodlander2","Ins_Worker2","Ins_Villager4","Ins_Woodlander1"];
_max = (count _allunitsK)-1;
_csardcount = 12;
_d = 0;
while {_d <= _csardcount} do 
{
	_unit = _mcsardgc createUnit [_allunitsK select (round random _max), _pos, [], 6, "FORM"];
	_unit setSkill 2+(random 3);
//	{_x addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}]} forEach (units _mcsardgb);

	_unit addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
	[_unit] join _mcsardgc;
	_d = _d+1;
	sleep 1;
};

/*

_allunitsK = ["Ins_Villager3","Ins_Woodlander3","Ins_Woodlander2","Ins_Worker2","Ins_Villager4","Ins_Woodlander1"];
_max = count _allunitsK;

_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
_allunitsD select round random (_max - 1) createUnit [_pos2, _mcsardgc];Sleep BIS_EVO_GlobalSleep;
hint format["mcsardgc count %1",(count units _mcsardgc)];

{_x addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}]} forEach (units _mcsardgc);
*/

_wp1 = _mcsardgc addWaypoint [_pos, 10];
_wp2 = _mcsardgc addWaypoint [_pos1, 10];
_wp3 = _mcsardgc addWaypoint [_pos3, 10];
_wp4 = _mcsardgc addWaypoint [_pos2, 10];
[_mcsardgc, 4] setWaypointType "CYCLE";

_recy = [_user,_pilot] execVM "data\scripts\grecycle.sqf";
_recy = [_user,_mcsardga] execVM "data\scripts\grecycle.sqf";
_recy = [_user,_mcsardgb] execVM "data\scripts\grecycle.sqf";	
_recy = [_user,_mcsardgc] execVM "data\scripts\grecycle.sqf";	

_pos = position vehicle _hostage;

_trgobj3 = createTrigger ["EmptyDetector", _pos];
_trgobj3 setTriggerActivation ["EAST", "NOT PRESENT", false];
_trgobj3 setTriggerArea [200, 200, 0, true];
_trgobj3 setTriggerTimeout [10, 10, 10, true ];
_trgobj3 setTriggerStatements ["this", "BIS_EVO_sobj1 = true", ""];

_start = createMarkerLocal ["look", _pos];
_start setMarkerColorLocal "ColorGreen";
_start setMarkerShapeLocal "RECTANGLE";
_start setMarkerSizeLocal [200, 200];
_start setMarkerBrushLocal "FDiagonal";

_obj1 setSimpleTaskDestination  _pos;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
sleep 1.001;
if (BIS_EVO_sobj1) then {_loop=1;};
//	if (_usergroup != (group _user)) then {_loop=1;};
if (not BIS_EVO_Onmission) then {_loop=1;};
if (not alive _hostage) then {_loop=1;};
};
//if (_usergroup != (group _user)) exitwith {[] call _Faild};
if (not BIS_EVO_Onmission) exitwith {[] call _Faild};
if (not alive _hostage) exitwith {[] call _Faild};

sleep 1.0;

_MissionBriefingHUD = localize "STR_M04t23_0";
_obj1 setSimpleTaskDescription [_MissionBriefingLong,_MissionBriefingShort,_MissionBriefingHUD];
_obj1 setSimpleTaskDestination position Boathouse;
["#00FF00",_txthmid,_txtbmid] call BIS_EVO_Message;

[_hostage] join _usergroup;

_hostage setdamage 0;
_hostage setCaptive false;
_hostage enableAI "MOVE";

_hostage doFollow (leader _usergroup);

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
sleep 1.001;
if (_hostage distance Boathouse < 10) then {_loop=1};
if (not alive _hostage) then {_loop=1};
if (not BIS_EVO_Onmission) then {_loop=1;};
};
if (not BIS_EVO_Onmission) exitwith {[] call _Faild};
if (not alive _hostage) exitwith {[] call _Faild};

_hostage action ["Eject",(vehicle _hostage)];	
unassignVehicle _hostage;
[_hostage] join grpNull;
{if(isplayer _x) then {_x doFollow leader _x}} foreach units (group _user);
["#FF0000",_txtpasshead,_txtpassbody] call BIS_EVO_Message;
[West,"HQ"] SideChat localize "STR_M04t65";playSound "Goodjob";
BIS_EVO_punit = _user;

BIS_EVO_prew  = _var;

publicVariable "BIS_EVO_prew";
publicVariable "BIS_EVO_punit";
//BIS_EVO_Onmission=false;
//_user removeSimpleTask _obj1;
//deleteMarkerLocal _start;
//deleteVehicle _trgobj3;
sleep 1.0;
_hostage doMove position Boathouse;  //may not move as sticks on carrier
[] call _deletemcsard;

I've just spent 18 hours over 2 days trying to rewrite every part of it, changing the positions, the createunit line format, the soldiertypes, adding in sleeps, ruling out all the other groups spawning in evo (planes, etc) and for some reason the 3rd group will NEVER spawn on any pos and with any unit type...

I have tried remming out most of the functions like the moveindriver etc but this makes no difference to the 3rd groiup actually spawning - the hint count function always returns a 0.

there are no reported script errors.

moving the creategroups from all being in the same place to being just before they are needed makes group 4 spawn more often now !

this is MP - i'm testing it running my own MP internet server

:confused:

can anyone see why this spawn failure would happen?

Edited by eggbeast

Share this post


Link to post
Share on other sites

aw i was really hoping someone could help me - i've spent 18 hours on this one script alread yand im totally flummoxed... go on i'll buy you a beer

Share this post


Link to post
Share on other sites

hey dyou know what? every time i ran it on my own server (on my pc) it failed but as soon as i put it up on the dedi box i t works like a dream.

now wtf is that about????

Share this post


Link to post
Share on other sites

Maybe you need to reinstall ArmA2 on your server?

Other than having a file messed up I don't see why it shouldn't work on another server.

My 2 cents. Best, Splicer.

Share this post


Link to post
Share on other sites

it happens a lot i've noticed. i run an mp server on my own box, fire up the mission for testing and have probs. can't fix them no matter how i try to re-script. then i ftp it onto my dedi-box, run the mision and it works perfectly. must be something to do with initialisation of the server when you don't join it, cos you're already on it or something... worth knowing about though otherwise you could spend hours tryingto crack the prob where there actually isn't one lol

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  

×