Jump to content
Sign in to follow this  
wolby2010

Creating Updating Enemy Counter

Recommended Posts

I need help with a scripting problem. I'm new at this so I have absolutely no idea how to do even the most basic scripting.

What I am doing is creating a mission whereby there is 1 BLUFOR and roughly 100 OPFOR spread out of the entirety of the Takistan map in order to practice my ability to track the enemy over large battlezones.

What I want to try and do is create a hint which updates every time I kill an enemy soldier with the remaining number of enemies as well as automatically create a marker where that soldier has died so that I know how many I have left to kill and where I have already killed to logically search the map for other enemies.

All the other posts which mention enemy counting are to do with the condition field of a trigger whereas I want a constantly displaying hint which updates every time an enemy soldier dies.

Would greatly appreciate it if someone could show me a script of how that could be done or point me in the direction of a script that already performs that function.

Many thanks

Share this post


Link to post
Share on other sites

just an example...

Put this code below to your init.sqf

enmc = {alive _x and side _x == east} count allUnits; 
{_x addEventHandler ["killed", {enmc = enmc -1; if (enmc != 0) then {hintsilent format["Enemy remaining : %1",enmc]} else {(_this select 0) cameraEffect ["Fixedwithzoom","top"]}; _mrk = createMarkerLocal [format["%1", enmc], getpos (_this select 0)]; format["%1", enmc] setMarkerTypeLocal "dot"; "_mrk" setMarkerColorLocal "ColorRed"}]} foreach allunits;
sleep 0.5;
player removeAllEventHandlers "killed";
titletext ["KILL 'EM ALL","plain"];
titleFadeOut 2;
sleep 2;
hintsilent format["Enemy remaining : %1",enmc];

waitUntil {enmc == 0};
sleep 3;
cuttext ["All enemy has been eliminated.","plain down"];
sleep 3;
titletext ["MISSION COMPLETED","plain",0.4];
cuttext ["","black out"];
sleep 4;
endMission "END1";

Edited by Morieza

Share this post


Link to post
Share on other sites
just an example...

Put this code below to your init.sqf

enmc = {alive _x and side _x == east} count allUnits; 
{_x addEventHandler ["killed", {enmc = enmc -1; if (enmc != 0) then {hintsilent format["Enemy remaining : %1",enmc]} else {(_this select 0) cameraEffect ["Fixedwithzoom","top"]}; _mrk = createMarkerLocal [format["%1", enmc], getpos (_this select 0)]; format["%1", enmc] setMarkerTypeLocal "dot"; "_mrk" setMarkerColorLocal "ColorRed"}]} foreach allunits;
sleep 0.5;
player removeAllEventHandlers "killed";
titletext ["KILL 'EM ALL","plain"];
titleFadeOut 2;
sleep 2;
hintsilent format["Enemy remaining : %1",enmc];

waitUntil {enmc == 0};
sleep 3;
cuttext ["All enemy has been eliminated.","plain down"];
sleep 3;
titletext ["MISSION COMPLETED","plain",0.4];
cuttext ["","black out"];
sleep 4;
endMission "END1";

...you can create OPFOR soldier as many as you want.

Wow it works thanks, I am in awe of your scripting wizardry

Share this post


Link to post
Share on other sites

oh is it possible to make a unit Cap with such unit counter?

Share this post


Link to post
Share on other sites

That example script didn't have function to exceed unit/group limitation, what I want to say was: he (wolby2010) could create unit more than 100 OPFOR (following his OP).

I have deleted "...you can create OPFOR soldier as many as you want." after 7 hours since the post #2 have been posted (see last edited date/time). Until now it just stick in wolby2010's post #3, I wish he edit that 'quote' too.

Edited by Morieza

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  

×