A3Antistasi / antistasi-1.x

Antistasi Unofficial Community old version
http://a3antistasi.enjin.com/
39 stars 44 forks source link

Air control WiP #322

Closed StefArma closed 6 years ago

StefArma commented 6 years ago

Reddit discussion: https://www.reddit.com/r/A3AntistasiOfficial/comments/8eltrs/wip_aircontrol_by_wurzel0701/

Fix #80 Fix #51

zalexki commented 6 years ago

Gosh those conditions are hard to read. One solution to enhance readability is to place your conditions in variables.

Example:

if (_hasSPAA) then {

//Despawn conditions: Stef - theese need to be tweaked
    waitUntil {sleep 1;
    (spawner getVariable _marker > 1) OR
        ((
            ({alive _x} count _allSoldiers < (_garrisonSize / 3)) OR
            ({fleeing _x} count _allSoldiers == {alive _x} count _allSoldiers)) AND     //Not sure about theese
            !(alive _SPAA) AND ({alive _x} count units _groupGunners == 0)
            )
        };
}

transformed into

if (_hasSPAA) then {
//Despawn conditions: Stef - theese need to be tweaked
    waitUntil {
        sleep 1;
        _isThirdOfGarrisonSomething = ({alive _x} count _allSoldiers < (_garrisonSize / 3));
        _isSomethingElse = ({fleeing _x} count _allSoldiers == {alive _x} count _allSoldiers);
        _isCombinationOfConditions = (_isThirdOfGarrisonAlive OR _isSomethingMeaningfull)
        _isCombinationAgain = ({alive _x} count units _groupGunners == 0) AND !(alive _SPAA)
        _isOtherCombination = ( _isCombinationOfConditions AND _isCombinationAgain )
        (spawner getVariable _marker > 1) OR (_isCombinationOfCombinations AND _isOtherCombination)
    };
}

This not tested but you get the idea : Use meaningful named variable containing the results of the complex conditions

Notice the is prefix, it's a common way to indicate the variable will be a boolean (true or false)

StefArma commented 6 years ago

Nice, yes those conditions are in multiple places.. i'll see what i can do

StefArma commented 6 years ago

have a look now