Jump to content
Sign in to follow this  
Deform

How to detect that spawned group is dead or alive + how to custom init

Recommended Posts

Hello.

So I've been making COOP mission and it starts by US forces getting ambushed inside a Takistan village. This is the script I use to spawn the enemies.

_mygroup = []; 
_mygroup2 = []; 

if (isServer) then {

_mygroup = [getmarkerpos "grp1", EAST, ["CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK74","CAF_AG_ME_T_PKM"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

_wp1 = _mygroup addWaypoint [getmarkerpos "wp1", 0]; _wp1 setWaypointType "MOVE"; _wp1 setWaypointSpeed "normal"; _wp1 setWaypointBehaviour "combat"; _wp1 setWaypointFormation "LINE";

_mygroup2 = [getmarkerpos "grp2", EAST, ["CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK74","CAF_AG_ME_T_PKM"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

_wp1 = _mygroup2 addWaypoint [getmarkerpos "wp1", 0]; _wp1 setWaypointType "sad"; _wp1 setWaypointSpeed "FULL"; _wp1 setWaypointBehaviour "aware"; _wp1 setWaypointFormation "LINE";

};

How I want this to work:

1. When player kill all the enemies. I want to assign new task. So I need way to detect when these spawned units are dead.

2. Custom init. I want to add these enemies "This allowFleeing 0", how I can add that.

So any advice what I need to add to this script?

Thanks in advance :)

- Deform

Share this post


Link to post
Share on other sites

waitUntil {
{alive _x} count (units _myGroup) == 0 &&
{alive _x} count (units _myGroup2) == 0
};

// --- New task stuff

Or maybe..

waitUntil {{alive _x} count (units _myGroup) + (units _myGroup2) == 0};

Share this post


Link to post
Share on other sites

For adding the init line:

{

_x allowFleeing 0;

} forEach units [_mygroup, _mygroup2];

Edited by JShock

Share this post


Link to post
Share on other sites

Thank you for insanely fast replies! Helped alot. This is what I have now:

_mygroup = []; 
_mygroup2 = []; 

_mygroup = [getmarkerpos "grp1", EAST, ["CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK74","CAF_AG_ME_T_PKM"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
_wp1 = _mygroup addWaypoint [getmarkerpos "wp1", 0]; _wp1 setWaypointType "MOVE"; _wp1 setWaypointSpeed "normal"; _wp1 setWaypointBehaviour "combat"; _wp1 setWaypointFormation "LINE";

_mygroup2 = [getmarkerpos "grp2", EAST, ["CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK74","CAF_AG_ME_T_PKM"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
_wp1 = _mygroup2 addWaypoint [getmarkerpos "wp1", 0]; _wp1 setWaypointType "sad"; _wp1 setWaypointSpeed "FULL"; _wp1 setWaypointBehaviour "aware"; _wp1 setWaypointFormation "LINE";

waitUntil {
   {alive _x} count (units _myGroup) == 0 &&
   {alive _x} count (units _myGroup2) == 0
};

p1 sidechat "script test";

That works perfectly. However if I add "Allowfleeing" command, it doesnt work anymore. This is what I tryed:

_mygroup = []; 
_mygroup2 = []; 

_mygroup = [getmarkerpos "grp1", EAST, ["CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK74","CAF_AG_ME_T_PKM"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
_wp1 = _mygroup addWaypoint [getmarkerpos "wp1", 0]; _wp1 setWaypointType "MOVE"; _wp1 setWaypointSpeed "normal"; _wp1 setWaypointBehaviour "combat"; _wp1 setWaypointFormation "LINE";

_mygroup2 = [getmarkerpos "grp2", EAST, ["CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK47","CAF_AG_ME_T_AK74","CAF_AG_ME_T_PKM"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
_wp1 = _mygroup2 addWaypoint [getmarkerpos "wp1", 0]; _wp1 setWaypointType "sad"; _wp1 setWaypointSpeed "FULL"; _wp1 setWaypointBehaviour "aware"; _wp1 setWaypointFormation "LINE";

{
_x allowFleeing 0;
} forEach units [_mygroup, _mygroup2];  

waitUntil {
   {alive _x} count (units _myGroup) == 0 &&
   {alive _x} count (units _myGroup2) == 0
};

player sidechat "script test";

Share this post


Link to post
Share on other sites

_allUnits = (units _mygroup1) + (units _mygroup2);
{_x allowFleeing 0;} forEach _allUnits;

waitUntil {sleep 5; {alive _x} count _allUnits == 0};
// create your task

Oh...Iceman ninjad me this time.

Anyway... always use a sleep, when you utilize in waitUntil for something like that!!!

You really don't need to count the units on every tick.

edit:

units [_mygroup, _mygroup2];

Are you sure that works? I don't think the units-command accepts an array as parameter.

Edited by Tajin

Share this post


Link to post
Share on other sites

Its working perfectly now, Im still pretty novice when it comes to scripting :confused: But again I learned something new, thanks again!

Share this post


Link to post
Share on other sites

edit:

Are you sure that works? I don't think the units-command accepts an array as parameter.

You would be right, I jumbled up a couple different ideas into one, my mistake :p.

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  

×