NickThissen 10 Posted December 28, 2013 Hi, I have a co-op mission where a certain interaction should cause everything in a certain range around some object to be destroyed (eg buildings and trees), but the players and their vehicles should remain unharmed. I am using a simple script that loops through every item in 'nearestObjects' and damages it, but this also damages the units (even if allowDamage is set to false first). I solved that by checking first if the current object is in the player's group: _grp = group squadLeader; _units = units _grp; { if (_x in _units) then { // object is in player's group, do something else } else { // destroy it _x setdamage 1; } } forEach (nearestObjects [(getpos objPos), [], 250]); This works, the units don't get killed but everything around them does. Now there is one problem remaining however: if the units happen to be in a vehicle, it will be destroyed and the units will die after all. How can I extend this check to also skip the vehicles that units might be inside of? If a unit happens to be NEAR a vehicle that is no problem, that vehicle should just explode and kill the unit, only the vehicles that units are actually in should remain alive. I could simply check if _x is in the vehicle of the squad leader (eg "_x in vehicle squadLeader") but that doesn't cover everything because some units may be in another vehicle. In other words; how do I extend this check so that it skips every vehicle that has a unit from the _units array inside it? Share this post Link to post Share on other sites
John Kozak 14 Posted December 28, 2013 (edited) _units = units _grp; { if (vehicle _x != _x && !(vehicle _x in _units)) // if there's a vehicle for a unit different than the unit itself, and this vehicle is not in the list yet _units set [count _units, vehicle _x]; // add it to the list; using "set" because it's faster } forEach _units; { if (_x in _units) then { <....> } } forEach (nearestObjects [(getpos objPos), [], 250]); Edited December 28, 2013 by DarkWanderer even better now Share this post Link to post Share on other sites
NickThissen 10 Posted December 28, 2013 Thanks, I didn't know you could add things to lists like that :) Share this post Link to post Share on other sites