Hey!
I asked this in the UCG forums and user Kramb answered. First, you need to add a cost to the unit you want to limit. Say, to archers (and crosbowmen and arbalesters), add unused resource 8. It’s resource id is 8
Now, you need to add an script call like this
const int cArcher = 4;
const int cArcherLimit = 10;
const int limitResource = 8;
rule limitArcher highFrequency {
for (player = 1; <= xsGetNumPlayers()) {
int count = xsGetObjectCountTotal(player, cArcher);
int resourceValue = cArcherLimit - count;
if (resourceValue >= 0) {
xsSetPlayerAttribute(player, limitResource, resourceValue);
} else {
xsSetPlayerAttribute(player, limitResource, 0);
}
}
}
This will make all players limit their archers to 10.
Hey! An easy solution with a trigger is shown in the following video about variables. If you start at 5:00 he explains it. It’s not as elegant as the solution above, but it works.
@CanineCrown7153 Do I understand this correct? I have to add the script above via the script trigger in the editor or elsewhere? Thanks for your answer in advance!