Jump to content
Sign in to follow this  
AlxPachino

Checking if all OPFOR is dead?

Recommended Posts

Right now I'm trying to create an objective based upon the number of OPFOR left. In my case, I'd prefer all of the OPFOR to be eliminated triggering that objective to be completed. I am very new to arma editing so I don't have much of a clue, but I have been doing little stuff here and there. I would be delighted if anybody could point me in the right direction into doing this.

Share this post


Link to post
Share on other sites

place a trigger with opfor not present and it will activate when all is either dead or not inside trigger area for opfor.

or this one is for all units, no matter where on the map:

if ( ({(side _x) == east} count allUnits) == 0 ) then {
  hint "no east units is alive";
};

this one is for individual groups.

if ( ({alive _x} count units groupname) == 0 ) then {
  hint "none in the group is alive";
};

this one is for array/list with any unit inside.

if ( ({alive _x} count [unit1,unit2,unit5,unit12]) == 0 ) then {
  hint "none in list is alive";
};

Share this post


Link to post
Share on other sites

So do I place if

( ({alive _x} count [unit1,unit2,unit5,unit12]) == 0 ) then {

hint "none in list is alive";

};

in the trigger?

Share this post


Link to post
Share on other sites

Just make a trigger and set the size for axis A and B to like 10000, and then select opfor in the drop down box and then click the button "not present." this will activate the trigger when there aren't any opfor in the trigger area

Share this post


Link to post
Share on other sites
So do I place if

( ({alive _x} count [unit1,unit2,unit5,unit12]) == 0 ) then {

hint "none in list is alive";

};

in the trigger?

You would put the ({alive _x} count [unit1,unit2,unit5,unit12] == 0) part in the condition field and the (hint "none in list is alive") part in the activation field. You would not use "then" ("then" is only necessary for if statements in scripts; condition fields in the editor just assume that syntax), and the parenthesis are not necessary.

Share this post


Link to post
Share on other sites
Thanks guys. I'm a noob when it comes to scripting, but I can C++. Wierd ain't it?

lol I have that too with an other scripting language (lsl2), took me several years to get the hang of that, with arma scripting it's starting over from scratch again. Thank god there is a helpful community :)

Share this post


Link to post
Share on other sites

I thought I'd add onto this thread as it had a great title for what I am trying to do. Here's the situation:

I have a BLUFOR base that will be attacked by randomly spawned groups of 24 OPFOR. What I need is a trigger to call the spawn. What I am thinking is that I never want more than 72 OPFOR on the map. I've scripted the spawning, but I need help with the trigger.

I was thinking of a trigger that counted the number of AI OPFOR on the map and when the number went to ~50 or so it would fire off the script, spawning another 24.

Any ideas?

Thanks,

-e

Share this post


Link to post
Share on other sites

Untested but try this as your condition line:

 
({(side _x) == east} count allUnits) <= 50

Make sure the side of your OPFOR is east or adjust accordingly.

Share this post


Link to post
Share on other sites

Well, it fired it off on map start which is good. I got my first 24. But it only fired the once. (I changed the trigger to Repeatedly) How long in between checks?

Share this post


Link to post
Share on other sites

If you mean how often the trigger checks the condition, it will do so most likely every frame.

Share this post


Link to post
Share on other sites

Right. So it only fired off the once. I have it set to BLUFOR Present, Repeatedly with a radius of the entire map.

Share this post


Link to post
Share on other sites

You can try this also mate...

Create a file called.... ummm.... "topup.sqf" in your mission folder.

Put this in it:-

private ["_i","_cnt"];

while {alive player} do {
_cnt = {(side _x) == east} count allUnits)};
if(_cnt <= 50) then {
	for "_i" from 0 to (72 - _cnt) do {
		[color="Red"]//spawn unit here... add your own code[/color]
		sleep 0.01;
	};
};
sleep 30;  [color="Green"]//check every 30 seconds[/color]
};

Execute this from anywhere at mission start. You can simply call it from your players init with:-

nul = [] execVM "topup.sqf";

No need for a trigger.

Untested by the way!! If it doesn't work you'll get the idea I'm sure.

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

There may be a conflict in the trigger parameters that I cannot see. Try placing a new trigger, said it to repeating, enter the condition code that I gave you , and put in your on activation code. If that still does not work, it may be easier to do this in the script like twirlys

Share this post


Link to post
Share on other sites

Thanks for all the help fellas. I tried the trigger a couple times, can't see what the issue is. I just wrapped up my spawn script in the loop from Twirly and it works great. Thanks again.

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  

×