Jump to content
Sign in to follow this  
jakerod

Detecting Dead Unit...

Recommended Posts

I have 3 T-72s moving to a certain location on the map. One of these T-72s has a 50% probability of being there.

I want to know when all 3 T-72s are no longer a threat.

I am using !(canMove tank) to detect if the tanks are immobile.

So it looks like this

Condition: !(canMove tank1) && !(canMove tank2) && !(canMove tank3)

On Act: tanksdead=1; hint "Tanks are dead"

The Problem: Tank3 is not there 50% of the time so the !(canMove tank3) will never trip off.

My 1st solution: !(canMove tank3) || !alive tank3

Problem 2: It doesn't work because it won't detect the tank is dead.

My 2nd Solution: !(canMove tank3) || tankmissing==1

Where tankmissing=1 is found in the "on act. line" of a trigger that says if vehicle(tank3) not present "on act." tankmissing=1.

Problem 3: This also won't work and I don't know why.

The only solution I can think of is some sort of complicated trigger deletion thing. However, its hard to test that it will work.

I was wondering if anyone can make my 2nd solution work by changing something.

EDIT: In place of "||" i've also tried "or" but it didn't matter.

EDIT #2: It does work with just the trigger but that only works if the tank is totally destroyed or missing not if it is only immobilized or missing.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">isNil "tank3"

Returns 'false', when the variable "tank3" has been initialised (which happens when the 3rd t72 is created)

Otherwise true

The real problem here is, that the expression

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">!(canMove tank3) can not be evaluated, when tank3 was not created. It returns neither 'true' nor 'false' but 'bool' (its datatype).

That causes every expression it is part of, to return 'bool' as well. And the triggers can't handle this returned value.

You need to split up those checks, for example in a little script which replaces the trigger:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(isNil "tank3") then {

       waitUntil {

               !(canMove tank1) &&

               !(canMove tank2)

       };

} else {

       waitUntil {

               !(canMove tank1) &&

               !(canMove tank2) &&

               !(canMove tank3)

       };

};

tanksdead=1;

hint "Tanks are dead";

Edit:

this works as well:

Condition:       {(canmove _x)} count [tank1,tank2,tank3] == 0

Activation:      tanksdead=1; hint "Tanks are dead";

'count' ignores the 'false' and 'bool' cases and counts only expressions that are 'true'

Share this post


Link to post
Share on other sites

EDIT: Thank you that code using "count" worked.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">isNil "tank3"

Returns 'false', when the variable "tank3" has been initialised (which happens when the 3rd t72 is created)

Otherwise true

The real problem here is, that the expression

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">!(canMove tank3) can not be evaluated, when tank3 was not created. It returns neither 'true' nor 'false' but 'bool' (its datatype).

That causes every expression it is part of, to return 'bool' as well. And the triggers can't handle this returned value.

You need to split up those checks, for example in a little script which replaces the trigger:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(isNil "tank3") then {

       waitUntil {

               !(canMove tank1) &&

               !(canMove tank2)

       };

} else {

       waitUntil {

               !(canMove tank1) &&

               !(canMove tank2) &&

               !(canMove tank3)

       };

};

tanksdead=1;

hint "Tanks are dead";

Thank you.

If I have the Condition fields set up in the following way:

tankmissing==1 || !(canMove tank3)

The problem is that it goes:

Okay tankmissing is true but then the !(canMove) returns nothing/bool so it makes the entire line unreadable? That is the problem correct? I just want to make sure I understand so I don't run into the same problem later.

Share this post


Link to post
Share on other sites
Quote[/b] ]Okay tankmissing is true but then the !(canMove) returns nothing/bool so it makes the entire line unreadable?

Yes, the whole expression.

To answer your edited question:

That script I posted is written in sqf, you run it with:   <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[] execVM "scriptfile.sqf";   When you run it from a init line in the mission editor you need to assign the return value to a varibale (any), like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">temp =  [] execVM "scriptfile.sqf";   Otherwise ArmA will spit out a "Type Script, expected Nothing" error

Edit:

When you're not sure what the return value is for some expression you can simply check it in game with a radio trigger.

On Activation:  hint format["%1", !(canmove tank3)];

Share this post


Link to post
Share on other sites
Quote[/b] ]Okay tankmissing is true but then the !(canMove) returns nothing/bool so it makes the entire line unreadable?

Yes, the whole expression.

To answer your edited question:

That script I posted is written in sqf, you run it with:   <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[] execVM "scriptfile.sqf";

  When you run it from a init line in the mission editor you need to assign the return value to a varibale (any), like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">temp =  [] execVM "scriptfile.sqf";   Otherwise ArmA will spit out a "Type Script, expected Nothing" error

Edit:

When you're not sure what the return value is for some expression you can simply check it in game with a radio trigger.

On Activation:  hint format["%1", !(canmove tank3)];

Thank you very much. The count thing is working well. If something goes wrong though I will keep your sqf idea in mind.

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  

×