peteruh 10 Posted March 6, 2013 Hey guys. I am pretty new to mission editing in Arma, and i was wondering how you can make a "enemy counter", so you know how enemies there are left. Really hope someone can help me? Share this post Link to post Share on other sites
Janat 10 Posted March 6, 2013 (edited) I'm not sure if this works in A3, but it did in A2. EDIT: I put the unnecessary stuff inside the spoiler Put this code somewhere during mission init: enemyCount = 0; Then create a script with a code like this: enemyCount = 0; forEachUnit side "OPFOR" {enemyCount=enemyCount+1}; hint format["Enemy count: %1", enemyCount]; To make the script repeat, you can use something like this: while true do {[i]the script you want to repeat[/i]}; Now I'm not completely sure whether the syntax is correct since I've had quite a long break from scripting, but I'm sure you can pick up the general idea and if this code doesn't work, find out the correct syntax and commands. :) Edited March 6, 2013 by Janat Share this post Link to post Share on other sites
dga 12 Posted March 6, 2013 Just a hint. If you use the while loop, consider using a sleep during the loop. Otherwise it will run on every frame. Which is baaaaad ;) 1 Share this post Link to post Share on other sites
Tuliq 3 Posted March 6, 2013 (edited) I would do: create a trigger covering all the map, activation OPFOR (or what side your enemy is), make it repeating, in the condition field write counter. on activation: hint format ["Enemies left: %1",count thislist]; counter=false; on deactivation: counter=true; then make another trigger, set the condition field to true, and in on activation write counter=true; should do the trick! Edited March 6, 2013 by Tuliq 2 Share this post Link to post Share on other sites
Janat 10 Posted March 6, 2013 (edited) Yeah, sleep 1 inside the while loop would repeat the script fast enough while being quite easy on the cpu. That trigger would work, too, but it's not as pretty (and somehow I have a feeling it would take a bit more processing power, which is hardly a problem if you're not running loads of scripts). Edited the counting script to actually do what the OP asked it to do. Edited March 6, 2013 by Janat Share this post Link to post Share on other sites
avibird 1 155 Posted September 21, 2020 A simple way is just use a radio trigger. place a trigger down anywhere. Size of the trigger 0 Type none Activation radio alpha ect Activation present Repeatable Trigger exp Condition player ==P1 (P1 is your player's name) if you want more then one guy to check how many enemies are left then player ==P1 || Player ==P2 On activation hint str ({side _x == east && {player distance _x < 6000} count allunits}; if your AO is bigger then make it 10000 Share this post Link to post Share on other sites
ZaellixA 384 Posted September 22, 2020 The rest of the people here have provided some simple solutions that (must) work quite well. Personally I would prefer something like // Assume that the opposing side is East/OPFOR private _numOfEnemies = east countSide allUnits; This of course would require some kind of timer to check in some kind of interval. Solutions like // 1st alternative // Run "forever" while {true} do { // Get the number of OPFOR units private _numOfEnemies = east countSide allUnits; // "Sleep" for 5 seconds uiSleep 5; } // 2nd alternative // Get the number of OPFOR units private _numOfEnemies = east countSide allUnits; // Run until all enemies are dead while {_numOfEnemies == 0} do { // Get the number of OPFOR units _numOfEnemies = east countSide allUnits; // "Sleep" for a while uiSleep 5; } Now, you may want the variable to be global, or public or something like that depending on when and where you intend to use it. Additionally, you may wish to make a function out of it if you intend to use it quite often (although this is just one line of code and I am not sure how much you would save by making a function out of it... If you intend to use it quite often in various places it may be worth it). One more tweak could be to get your player's faction/side and count all units that do not belong to the same faction as enemies. One approach to that (most probably there are more) could be // Use a single variable to save some memory (although it may be not worth it, feel free to follow your style) private _numOfEnemies = (side player) countSide allUnits; // Get all the units on the same side with the player _numOfEnemies = allUnits - _numOfEnemies; // Exclude the units on the same side with the player from "all the units" Finally, you could count the enemies (based on your player's faction and game's setup, the opposing factions may vary). This could possibly be done like // Count the units that are considered enemies for the player private _numOfEnemies = player countEnemy allUnits; Please keep in mind that countEnemy counts also the "renegades" (friendly units that have done some friendly kills, etc.) and all units that are considered enemies. For the sides' relationships please refer to this page. You can also check the same page for ways to change hostility between sides (one- or two-way hostilities included). You can get information about side hostilities in the scripts with the helper functions: BIS_fnc_sideIsFriendly and BIS_fnc_sideIsEnemy. 2 Share this post Link to post Share on other sites
rodrigoglowacki 1 Posted July 21, 2021 On 3/6/2013 at 6:50 PM, Tuliq said: I would do: create a trigger covering all the map, activation OPFOR (or what side your enemy is), make it repeating, in the condition field write counter. on activation: hint format ["Enemies left: %1",count thislist]; counter=false; on deactivation: counter=true; then make another trigger, set the condition field to true, and in on activation write counter=true; should do the trick! is there any way to do this without sounding the message? with hintsilent for example? 1 Share this post Link to post Share on other sites
beno_83au 1369 Posted July 21, 2021 @rodrigoglowacki have you tried hintSilent? 1 Share this post Link to post Share on other sites
XSDNA 0 Posted Monday at 12:47 PM On 3/6/2013 at 9:50 PM, Tuliq said: I would do: create a trigger covering all the map, activation OPFOR (or what side your enemy is), make it repeating, in the condition field write counter. on activation: hint format ["Enemies left: %1",count thislist]; counter=false; on deactivation: counter=true; then make another trigger, set the condition field to true, and in on activation write counter=true; should do the trick! Haha this works in 2025, I just signed up to thank you! Share this post Link to post Share on other sites
pierremgi 4934 Posted Monday at 02:09 PM In initPlayerLocal.sqf (or trigger, set to true) addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer", "_instigator"]; if (isNull _instigator) then { _instigator = UAVControl vehicle _killer select 0 }; if (isNull _instigator) then { _instigator = _killer }; private _side = side group _killed; if (_side getFriend side _instigator < 0.6) then { private _cnt = _side countSide allunits; hintSilent format ["Remaining %1 units: %2",_side,_cnt]; }; }]; 1 Share this post Link to post Share on other sites