Page 1 of 1

Unit Design - Unit Propery sheet - category logical operators

Posted: Tue Oct 29, 2019 7:14 am
by Stratego (dev)
New codewords can be used to set AND and NOT operators within category definitions.

cases where you can use:
All place where you fill "unitTypes" definition you can set "categories" and in these you can use this feature.
eg in:
- trnBuilders
- trnModifiers
- trnBonusList
and so on.


"AND(" and ")" : AND codeword makes all categories listed later until ")" codeword treated as inside logical AND brackets, so unit has to have all categories (or not have in case of negations) to be added to proper list.

"NOT" : makes all units in next category excluded from final list, but "NOT" inside AND brackets are treated separately, so categories: ["AND(", "FOOT", "NOT", "MELEE", ")", "MELEE_FOOT"] should have all foot units, but "categories":["FOOT", "NOT", "MELEE", "MELEE_FOOT"] would have no melee foot units.

Example excluding multiple categories from a bigger category
If you want all air units that are not jet planes, not seaplanes than use this form:
{"categories":["AND(", "U_AIR_UNITS", "NOT", "U_JET", "NOT", "U_PLANES_SEAPLANE", "NOT", "U_PLANES_NO_AIRCARRIER", ")"]},

ATTENTION! a category will be evaluated properly ONLY if it has at least one unit assigned to it!

Example:
Affecting living knights, all melee foot and archers, but none of all this can be mechanical:
In json [and(, mounted, melee, not, undead, ), and(, melee, foot, ), archers, not, mechanical]

So normal NOT is global for bonus, but in AND brackets it only excludes within it.

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Tue Oct 29, 2019 7:53 am
by makazuwr32
Great!

@Alexander82

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Sun Oct 24, 2021 10:18 pm
by Stratego (dev)
ATTENTION! a category will be evaluated properly ONLY if it has at least one unit assigned to it!

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Fri Nov 26, 2021 4:51 pm
by L4cus
does "trnModifiers" still work?

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Fri Nov 26, 2021 5:00 pm
by Midonik
No - you must now use trnValidTargets on techs instead.

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Fri Nov 26, 2021 7:37 pm
by L4cus
good

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Thu Mar 10, 2022 7:41 pm
by Stratego (dev)
new example:
Example excluding multiple categories from a bigger category
If you want all air units that are not jet planes, not seaplanes than use this form:
{"categories":["AND(", "U_AIR_UNITS", "NOT", "U_JET", "NOT", "U_PLANES_SEAPLANE", "NOT", "U_PLANES_NO_AIRCARRIER", ")"]},

Re: Unit Design - Unit Propery sheet - category logical operators

Posted: Thu Mar 10, 2022 8:14 pm
by Stratego (dev)
fixed example updated above.