fawlty 30 Posted October 9 activation of a trigger I'm trying to use this directed to opfor in this case east {[_x, 2500] execVM "fn_taskRush.sqf"} forEach nearestObjects [cap0_1, ["all"], 51]; I want to change "all" to "east" but it's more complicated than that. I use this to have patrolling opfor forces rush us. If I leave it as "all" the civilians will also approach us. Share this post Link to post Share on other sites
soldierXXXX 110 Posted October 9 Hi, if you need to return opfor units + opfor vehicles you can filter them with select command nearestObjects [cap0_1,["O_Soldier_base_F","LandVehicle"],51] select {side _x == EAST}; But if you need only on foot units it might be better use nearEntities which is much faster cap0_1 nearEntities [["O_Soldier_base_F"],51]; 1 Share this post Link to post Share on other sites
JCataclisma 80 Posted October 9 Try something like this: private _nearbyEastTroops = nearestObjects [cap0_1, ["Man"], 51] select {_x isKindOf 'SoldierEB'}; {[_x, 2500] execVM "fn_taskRush.sqf"} forEach _nearbyEastTroops; 1 1 Share this post Link to post Share on other sites
fawlty 30 Posted October 9 soldierXXXX, I probably have this wrong {[_x, 2500] execVM "fn_taskRush.sqf"} forEach nearestObjects [cap0_1 nearEntities [["O_Soldier_base_F"],51]];it's a no go JCataclisma. worked great. BTW; if I want to make west the enemy do I just change the 'nearbyEastTroops' to 'nearbyWestTroops' I'm not sure about that 'SoldierEB' bit Thanks to you both Edit; just tried it out and it looks like east to west is all that's needed Thanks again Share this post Link to post Share on other sites
JCataclisma 80 Posted October 10 11 hours ago, fawlty said: BTW; if I want to make west the enemy do I just change the 'nearbyEastTroops' to 'nearbyWestTroops' I'm not sure about that 'SoldierEB' bit Mostly, no...and yes. 😂 Providing _nearbyEastTroops is just a custom/random name I've chosen for such variable, it could be ANY other name, like "_closeEnemies", "_nearestTargets", or whatever. 'SoldierEB' ('E' is for 'East') is the config name/kindOf for the Opfor units, which you can find when you go in the editor, right-click on the unit and check the "View in config file". The combination of 'Man' and 'SoldierEB' is what actually does the trick, so you can use 'SoldierGB' for Independent faction ('G' for 'Guerrilla') and 'SoldierWB' for Bluefor/West. I forgot to mention that such code I use is specifically for soldiers, not necessarily targeting vehicles. Just as a more clear example, this is what I am currently using, some kind of fake gas bomb, which should act differently upon each kind of "people" nearby its area of impact ('_charge_9' is the variable name for the gas bomb): private _nearbyEastTroops = nearestObjects [_charge_9, ["Man"], 7] select {_x isKindOf 'SoldierEB'}; private _nearbyGuerTroops = nearestObjects [_charge_9, ["Man"], 7] select {_x isKindOf 'SoldierGB'}; private _nearbyBlueTroops = nearestObjects [_charge_9, ["Man"], 7] select {_x isKindOf 'SoldierWB'}; sleep 4; { _x setDamage 1; } forEach _nearbyEastTroops; { _x setDamage 1; } forEach _nearbyGuerTroops; { _x setUnconscious true; } forEach _nearbyBlueTroops; sleep 2; 1 1 Share this post Link to post Share on other sites
soldierXXXX 110 Posted October 10 7 hours ago, fawlty said: soldierXXXX, I probably have this wrong {[_x, 2500] execVM "fn_taskRush.sqf"} forEach nearestObjects [cap0_1 nearEntities [["O_Soldier_base_F"],51]];it's a no go Yep, you got this wrong. You can't combine nearestObjects with nearEntities. It's either one or the other. So like this: {[_x, 2500] execVM "fn_taskRush.sqf"} forEach cap0_1 nearEntities [["O_Soldier_base_F"],51]; You can of course change O_Soldier_base_F for SoldierEB,SoldierWB or SoldierGB. O_Soldier_base_F is child of SoldierEB. 1 Share this post Link to post Share on other sites
fawlty 30 Posted October 10 Figured I had it wrong, although I did try various formats re; You can't combine nearestObjects with nearEntities Hate to say it but I'm still getting error msg's with {[_x, 2500] execVM "fn_taskRush.sqf"} forEach cap0_1 nearEntities [["O_Soldier_base_F"],51]; Share this post Link to post Share on other sites
soldierXXXX 110 Posted October 10 Yep, probably would be better to put it between round brackets I tested it with this, {[_x, 2500] spawn {params ["_unit","_number"];systemChat str ("Unit:" + str _unit + " Number: " + str _number)}} forEach (player nearEntities [["O_Soldier_base_F"],51]); So your code should look like this {[_x, 2500] execVM "fn_taskRush.sqf"} forEach (cap0_1 nearEntities [["O_Soldier_base_F"],51]); Also I noticed that you had there empty characters, which also causing errors. If you're satisfied with @JCataclisma's code (which works), there's no actual need to change that. We're talking about milliseconds here, so regular users won't notice the difference anyway 🙂. 1 Share this post Link to post Share on other sites
fawlty 30 Posted October 10 Yup that got it soldierXXXX, just needed a set of brackets. JCataclisma works but it was good to get your script to work as well. Thanks again to both of you for the help. Cheers 1 Share this post Link to post Share on other sites