Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
ezremake

Counting Unit Scores

Recommended Posts

I'm having a hard time counting the score of groups of units.

 

For instance, I have a trigger with the condition

 

score p1 + score p2 + score p3 >= 10

 

Which works fine assuming p1/p2/p3 are all present, but if one or two of them aren't, the script doesn't run.

 

I've even tried doing it in combinations i.e

 

score p1 + score p2  >= 10 || score p2 + score p3 >= 10 || score p1 + score p3 >= 10 || score p1 + score p2 + score p3 >= 10

 

But it only works when all units are available. How do I go about doing this?

 

 

Share this post


Link to post
Share on other sites


_score = 0;

{

if (!(isNil _x)) then {

_unit = missionNamespace getVariable _x;

_score = _score + (score _unit);

};

}

forEach ["p1", "p2", "p3"];

_score >= 10

Share this post


Link to post
Share on other sites

Thanks for the reply Schatten!

 

Forgive my newbiness,  but what would be the best way to incorporate that script? I've tried running it through a loop, but that just continually adds score on top of itself.

 

**EDIT**

 

Ended up making some adjustments, and running it through a loop. Seems to work great now.

{
    if (!(isNil _x)) then {
        _unit = missionNamespace getVariable _x;
        
        _oldScore = _unit getVariable["OldScore",0];
        _currentScore = score _unit;
        _diffScore = _currentScore - _oldScore;

        scoreSquad1 = scoreSquad1 + _diffScore;
        publicVariable "scoreSquad1";
        _unit setVariable["OldScore", _currentScore, true];
        hint format ["%1",scoreSquad1];
    };
}
forEach ["s1", "s2", "s3", "s4"];

Share this post


Link to post
Share on other sites

what would be the best way to incorporate that script?

Simply add my code into condition field of trigger.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×