Jump to content
Sign in to follow this  
jandrews

alive question.

Recommended Posts

I am attempting to have several tasks with multiple veh's listed for tasks to be destroyed, once all destroyed task is complete.

However, I have been trying several different combo's for this alive and nothing seems to work.

I have tried

enemyDead = false;

waitUntil {{ alive _x } count [_arty1, _arty2, _Ammot] == 0};

waitUntil {((!alive unit1) and (!alive unit2) and (!alive unit3))};

waitUntil {(!alive unit1) and (!alive unit2) and (!alive unit3)};

waitUntil {!alive car1 AND !alive car2 AND !alive car3};

am running out of ideas. I keep getting the /#/ and dont know what, why.

Share this post


Link to post
Share on other sites

waitUntil{!alive car1 && !alive car2 && !alive car3};

will work as long as the cars actually exist on the map somewhere. I would use && instead of AND because it looks better (OR's equivilent is ||)

Share this post


Link to post
Share on other sites
am running out of ideas. I keep getting the /#/ and dont know what, why.

Where is this (#) showing up? Could you post a screenshot, or a bigger block of the code?

Edited by JShock

Share this post


Link to post
Share on other sites

I have tried that and others not listed and not sure why its not taking it.

---------- Post added at 03:52 ---------- Previous post was at 03:42 ----------

enemyDead = false;
waitUntil {{ alive _x } count [_sniper1, _sniper2, _hq] == 0};

enemyDead = false;

waitUntil {{ alive _x } count [_sniper1, _sniper2, _h>

20:46:06 Error position: <alive _x } count [_sniper1, _sniper2, _h>

20:46:06 Error alive: Type Group, expected Object

Share this post


Link to post
Share on other sites

Your _sniper1, _sniper2, and _hq, one or more of these are groups, that's why it's saying "type group" in the error, and there is more than one unit in one or more of those variables, and the alive command can only check one unit at a time, so try something like this:

waitUntil {{ alive _x } count units [_sniper1, _sniper2, _hq] == 0};

Edited by JShock

Share this post


Link to post
Share on other sites
Your _sniper1, _sniper2, and _hq may contain more than just one unit, that's why it's saying "type group" in the error, because the is more than one unit in one or more of those variables, and the alive command can only check one unit at a time, so try something like this:

waitUntil {{ alive _x } count units [_sniper1, _sniper2, _hq] == 0};

wow, learn something today about alive, thanks jshock. and the other thing worked too.

---------- Post added at 04:09 ---------- Previous post was at 03:59 ----------

getting a similar error now. Am I asking too much when I have groups included?

21:05:00 Error in expression < = false;

waitUntil {{ alive _x } count units [_sniper1, _sniper2, _hq] == 0};

>

21:05:00 Error position: <units [_sniper1, _sniper2, _hq] == 0};

>

21:05:00 Error units: Type Array, expected Object,Group

Share this post


Link to post
Share on other sites

Derp, my fault, try this:

waitUntil {{ alive _x } count ((units _sniper1) + (units _sniper2) + (units _hq)) == 0};

Share this post


Link to post
Share on other sites
Derp, my fault, try this:

waitUntil {{ alive _x } count ((units _sniper1) + (units _sniper2) + (units _hq)) == 0};

Ok, so what it looks like is anything with multiple units need this ^^^. will give it a try.

Share this post


Link to post
Share on other sites

Yea so basically, to talk you through that code, the units command returns an array of units in the defined group, arrays can be added together no different from numbers, to make one single array, except that when adding, arrays combine elements not values, then the count command works its way through each element of the array (each of the units) and checks if they are alive, so on and so on until the last element is tested, then count returns the number of elements that met the condition (the number of alive units), so if count returns 0, that means none of the units in any of those groups are alive, and that returns true, which terminates the waitUntil, allowing the script to move forward.

Edited by JShock

Share this post


Link to post
Share on other sites

Ok, so if _hq is an empty vehicle would I do this?

waitUntil {{ alive _x } count ((units _sniper1) + (units _sniper2) + (units _hq)) == 0};

waitUntil {!alive _hq && { alive _x } count ((units _sniper1) + (units _sniper2) == 0};

Share this post


Link to post
Share on other sites

Yea, and you missed a couple paraenthesis, fixed below:

waitUntil {!alive _hq && ({ alive _x } count ((units _sniper1) + (units _sniper2) == 0))};

You could also throw in a lazy evaluation instead, basically all that does is if the first checked condition isn't true, stop checking the rest of the condition (just makes the code run a bit faster):

waitUntil {!alive _hq && { { alive _x } count ((units _sniper1) + (units _sniper2) == 0)} };

Edited by JShock

Share this post


Link to post
Share on other sites

2 questions.

1.Still getting an error, wondering if its the extra {} in line. But not sure.

waitUntil {!alive _hq && { { alive _x } count ((units _sniper1) + (units _sniper2) == 0)} };

19:37:00 Error in expression <nt ((units _sniper1) + (units _sniper2) == 0)} };

_null = [["mob_snipers", ">

19:37:00 Error position: <== 0)} };

_null = [["mob_snipers", ">

19:37:00 Error ==: Type Array, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Network Object,Team member,Task,Location

19:37:00 File C:\Users\Andrews\Documents\Arma 3\missions\COOP_36_SOW.Altis\scripts\makeClearOps.sqf, line 352

2. I have never seen this before, But have a feeling its referring to the direction of each group, should I be placing [] around the random (360)? As you can see its for several groups, probably each that I am spawning. I have an example in the spoiler. look for <-------

19:37:24 "Andrews/log: ERROR: [bIS_fnc_spawnGroup] #3: 60.2604 is type SCALAR, must be ARRAY. [] used instead."

19:37:24 "Andrews/log: ERROR: [bIS_fnc_setRank] is not a valid rank"

19:37:28 "Andrews/log: ERROR: [bIS_fnc_spawnGroup] #3: 212.781 is type SCALAR, must be ARRAY. [] used instead."

19:37:28 "Andrews/log: ERROR: [bIS_fnc_setRank] is not a valid rank"

19:37:29 Warning: Destruction of 99ffb200# 1602632: highvoltagecolumnwire_f.p3d owned by a static object (99ffb200# 1602632: highvoltagecolumnwire_f.p3d)

19:37:35 "Andrews/log: ERROR: [bIS_fnc_spawnGroup] #3: 69.8888 is type SCALAR, must be ARRAY. [] used instead."

19:37:48 "Andrews/log: ERROR: [bIS_fnc_spawnGroup] #3: 63.4606 is type SCALAR, must be ARRAY. [] used instead."

fn_spawnSearchDestroyMission = {

hint "COMBAT OPS UPDATED";

//creating the marker 

_markerCO = createMarker ["SD", _mrkSpawnPos];
_markerCO setMarkerType "mil_warning";
_markerCO setMarkerColor "ColorRed";
_markerCO setMarkerText "CLEAR OP";
_markerCO setMarkerSize [1,1];

_null = [[RESISTANCE,WEST], "SD", ["Destroy the rebel camp", "clear area", "clear area"], getMarkerPos "SD", false] spawn BIS_fnc_taskCreate;
_null = ["SD", "CREATED"] spawn BIS_fnc_taskSetState;

//creating the vehicle

_newPos = [getMarkerPos _markerCO, 0, 50, 10, 0, 20, 0] call BIS_fnc_findSafePos;

_newOffsetPos = [((_newPos select 0) + 100), ((_newPos select 1) - 25), (_newPos select 2)];

_camps_classes = ["CampA","CampB"] call BIS_fnc_selectRandom;

_hq = [(getMarkerPos _markerCO), EAST, (configfile >> "CfgGroups" >> "Empty" >> "Guerrilla" >> "Camps" >> (_camps_classes)),random 360] call BIS_fnc_spawnGroup;  <------------------
_covernet = createVehicle ["CamoNet_OPFOR_big_F", (getMarkerPos _markerCO), [], 0, "CAN_COLLIDE"];
_covernet attachTo [_hq,[0,0,0]];
sleep 1;
detach _covernet;

_or1 = [[((_newPos select 0) + 35), (_newPos select 1),0],random 360,"I_G_Offroad_01_armed_F",East] call BIS_fnc_spawnVehicle;
nul = [_or1, _newPos] call BIS_fnc_taskDefend;

_ammo = createVehicle ["O_supplyCrate_F",[((getPosATL _hq select 0) - 10), getPosATL _hq select 1,0],[], 0, "NONE"];
_ammo setDir random(360);

enemyDead = false;
waitUntil {!alive _ammo && { { alive _x } count ((units _or1) == 0)} };

_null = [["S&D", "SUCCEEDED"],"BIS_fnc_taskSetState", true, true] call BIS_fnc_MP;

sleep 5;

{deleteVehicle _x} forEach crew _or1;
deleteMarker _markerCO;
deleteVehicle _or1;
deleteVehicle _hq;
deleteVehicle _ammo;
deleteVehicle _covernet;

GlobalHint = "Good Job!";
publicVariable "GlobalHint";
hintSilent GlobalHint;

GlobalSCHat = "OBJECTIVE COMPLETED";
publicVariable "GlobalSCHat";
player sideChat GlobalSCHat;

[[RESISTANCE,WEST], "SD"] call LARs_fnc_removeTask;
};

Share this post


Link to post
Share on other sites

Ok, didn't realize _hq was just a bunch of objects, it would be a bit tougher to check for all those to be "dead", so it would just need to be this:

waitUntil { { alive _x } count ((units _sniper1) + (units _sniper2)) isEqualTo 0 };

You can't use the random 360 where you had it, it's only allowed in the last parameter of BIS_fnc_spawnGroup:

_hq = [(getMarkerPos _markerCO), INDEPENDENT, (configfile >> "CfgGroups" >> "Empty" >> "Guerrilla" >> "Camps" >> (_camps_classes)),[],[],[],[],[],(random (360))] call BIS_fnc_spawnGroup;

And as far as the BIS_fnc_setRank issue, I don't believe that can be fixed, as I looked in the config at the camps, and their ranks are set as (""), an empty string, I tried using the BIS_fnc_spawnGroup parameter to set ranks, but to no avail.

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  

×