Jump to content
Sign in to follow this  
james mckenzie-smith

What is the OPPOSITE of Alive "unitname"?

Recommended Posts

I have searched for the opposite of 'Alive "unitname"', whereby a unit is only present at the start of a mission if another is determined to be NOT present. I have not found it, alas. Is there such a command in ArmA2? I know for a fact that there was one in OFP, but it has been a long time since I have made any OFP scenarios, so I have forgotten. Any ideas?

Share this post


Link to post
Share on other sites

! or NOT negates the result.

If alive player returns true then !alive player will return false and vice-versa.

However the command you are looking for here is isNull.

if (isNull guy1) then
{
    hint "Unit guy1 does not exist!";
};

Share this post


Link to post
Share on other sites

Thanks for the assistance. Now, up until now, I have been placing 'Alive guy1' in the Condition of Presence field of the Unit Edit menu of a unit that is to be present only if a specific other unit appears. This works flawlessly; if, say, unit 'guy2' is present on 'Alive guy1' and guy1 has a 50% chance of appearing, then guy2 will only appear when guy1 appears.

However, if I put 'isNull guy1' in the Condition of Presence field in guy2's Unit Edit menu, then it just does not appear at all, regardless of what is going on with guy1. '!alive guy1' is similarly ineffective.

Any idea as to where I am going wrong?

Once again, thanks for your assistance!

Share this post


Link to post
Share on other sites

I use

!alive name_of_unit

or

not alive name_of_unit

---

to check more units in a single trigger i use:

!alive t1 && !alive t2 && !alive t3

t1-t3 = target names (persons, vehicles etc.)

Share this post


Link to post
Share on other sites

Its ment to be used in the trigger condition or script file.

Share this post


Link to post
Share on other sites

It used to work correctly in the Conditions of Presence field in OFP, at any rate. Not sure why is doesn't work now, as something like 'alive guy1' works just fine.

Share this post


Link to post
Share on other sites

Just a guess. Have you tested it the other way around? The units (and their cond fields) are read from the mission file in order, so if you try to check in the first unit's field if the 2nd is alive (or not alive), it obviously should return false (or error as it's nil) always as it's not even present at the time of the check.

However, you might as well do it the common way; both units have 100% cond of presence, then you use deletevehicle.

Share this post


Link to post
Share on other sites

I tried this awhile ago. In my mission I had a 50/50 chance of an assault coming from the north or the west but never both.

The cond of presence line !alive = guy1 never worked, I'm guessing because both units are placed at the same moment at mission start up.

I think I used a game logic with a probability of presence at 50% and a trigger to detect its presence at mission start.

If true, the trigger would move the single squad from thier start position to the alternate start position which I set as an invisible H.

I'll update when I am at home this afternoon and able to provide all the details.

Share this post


Link to post
Share on other sites
I tried this awhile ago. In my mission I had a 50/50 chance of an assault coming from the north or the west but never both.

The cond of presence line !alive = guy1 never worked, I'm guessing because both units are placed at the same moment at mission start up.

I think I used a game logic with a probability of presence at 50% and a trigger to detect its presence at mission start.

If true, the trigger would move the single squad from thier start position to the alternate start position which I set as an invisible H.

I'll update when I am at home this afternoon and able to provide all the details.

A much easier way to achieve this behaviour would be placing only one group at position A and an empty marker at position B, which you than group with the units leader. All units in the group should have "in formation" in start condition or whatever (czech version here :S). And voila the attack will come from original position or from the markers position

Share this post


Link to post
Share on other sites

Thank you all for your assistance. Much appreciated.

Avoidable, that would work, except for the thorny issue of waypoints. Would that not mean that, whatever direction the attack comes from, the attacking units would only share a single waypoint system? That would not be satisfactory for obvious reasons.

PJ[CZ], there are two problems with that suggestion. First, as I mentioned to Avoidable, the waypoint problem exists, but additionally, what if a mission maker wants to have say ten squads and vehicles attacking from one direction or another? The system you describe could result in five units attacking from one side, and five from another, or seven and three, or whatever.

I am still looking for an adequate solution. At any rate, this worked easily in OFP; perhaps the fact that it is not working now could be logged as a bug. Thoughts?

Thanks again.

Share this post


Link to post
Share on other sites

Just been fighting with a similar issue, but I believe I have a solution that fits the original poster's requirements.

Just to be clear, here's my requirement and then my resolution:

Requirement:

I want my coop team to be uncertain as to exactly what they're going to face, even if they've played the mission before. However, I want to be certain that there's going to be some enemy and not, by chance, no enemy (or, just as bad, so many enemies that the mission is not possible).

For example, my coop team are intercepting and destroying a convoy. The convoy will call for help if it gets chance. On standby is a helicopter. Most of the time, I want it to be an armed passenger helicopter but around 25% of the time I want it to be a lean and mean attack helo.

Attempts (that didn't work):

Taking the helicopter example, I have two named helicopters called "rus_helo1" and "rus_helo2".

rus_helo1 has a probability of presence of 75% and a condition of presence of "true".

I want rus_helo2 to only but always appear when rus_helo1 does not appear.

I tried a probability of presence for rus_helo2 of 100% and a condition of presence of:

(!alive rus_helo1)

rus_helo2 will never appear, even when rus_helo1 is not in play.

Successful solution:

Setting rus_helo2 condition of presence appears to be an incorrect approach (maybe due to a bug?) as, apparently, rus_helo1 is always alive when the check occurs.

Instead, setup rus_helo1 exactly as above, then do the following for rus_helo2:

Condition of presence: true

Probability of presence: 100%

Initialisation: if (alive rus_helo1) then { deleteVehicle this }

I guess that speaks for itself but for the newbie coders this means that rus_helo2 will always be placed initially, but when it comes to actually setting it up (i.e initialising it) it'll make another check to see if rus_helo1 is in play. If rus_helo1 does exist, rus_helo2 will delete itself as if it never existed.

This means that I always get one helo or the other but never both.

This also avoids the waypoint issues identified with previous solutions as each helo has its own waypoints.

A slight issue is that, in this case, I need to wire both helo's Hold waypoints up to a Switch trigger, which essentially means I have a maintenance complication. That's just a design consideration, though, not a flaw with the approach for conditional presence.

Hope that helps.

Share this post


Link to post
Share on other sites

Ronin Storm, I just noticed this now. It works! Good solution, I can now do the things that I wanted to with several missions that I have in development.

Thanks!

Share this post


Link to post
Share on other sites

?, !, &&, || etc are for use in scripts, for trigger and other fields you neet to use ... if, not, and, or ...

?, !, &&, || will not work in dialog fields.

Planck

Share this post


Link to post
Share on other sites

Right, so the implication of that is that if I'd made the presence condition for rus_helo2 more like:

(not alive rus_helo1)

... then that would have worked?

Share this post


Link to post
Share on other sites

A problem with using units init field for this sort of thing other than reasons posted is that you probably dont know in what order the init fields will be executed. For example I tried adding several vehicles to an array by using first xT = [this] for one unit and then xT = xT + [this] for all other units and to my surprise there were only 2 units out of bout 7 in the array after missions start. The reason for this is that the unit with the init field creating the array was initialized second last so other units were trying to add to a non existing array.

The way I solve a problem like yours is for example the following:

Create a game logic and put this in the unitfield: xRnd = round(random 1)

create a trigger with size 50 or whatever covers the whole group you want deleted/not deleted and set activation to anybody present.

Condition: this and (xRnd == 0)

Activation: {deleteVehicle _X} forEach thisList

Then make a similar trigger for the second group but change condition of xRnd to 1 instead of 0.

Share this post


Link to post
Share on other sites
?, !, &&, || etc are for use in scripts, for trigger and other fields you neet to use ... if, not, and, or ...

?, !, &&, || will not work in dialog fields.

Planck

Not really. Only the outdated SQS "? condition : expression" won't work there. You can use !, &&, || anywhere you want.

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  

×