ck2plus / CleanSlate

A community resource, clean base from which to begin mods for CrusaderKings 2
29 stars 13 forks source link

The engine does not handle " < " correctly for "count" and "demesne_size" #177

Closed VisarDomi closed 11 months ago

VisarDomi commented 11 months ago

CleanSlate uses < a lot, where the base game does not use it anywhere for certain conditions, like count and demesne_size.

Count is mentioned here: https://ck2.paradoxwikis.com/Scripting#Count

"In practice, some mod developers have had difficulty using < and <= operators with the count condition. (In particular, the base game only ever uses count = and count >=, so it's possible any bugs were simply never noticed by the developers.)"

"count < 2" does not work, so you have to invert the logic. Same for demesne_size. Take a look at the trigger section of a character_event:

trigger = {
    NOT = {
        any_child = {
            count >= 2
            is_female = yes
        }
    }
}

That works as intented. This one does not work though:

trigger = {
    any_child = {
        count < 2
        is_female = yes
    }
}

The second one is more readable. It checks if the character has less than two daughters. Too bad it doesn't work.

Makes you wonder how many similar pitfalls to this there are.

schwarherz commented 11 months ago

To clarify, have you tested this? The wiki information is not always up-to-date. I know that < and <= did not work in the past but was under the impression that that had been fixed and paradox just kept doing it the old way because they have a tendency to do that.

VisarDomi commented 11 months ago

yeah, I actually just finished testing count, demesne_size and realm_size. count fails, demense_size fails while realm_size works as intended. I found about count because of a small mod I made, while demesne_size because of ck2plus, where the modifier for small demesne was active on a large demesne.

Checkout this branch, and test it yourself while playing the byzantine emperor in the default 1066 start date:

https://github.com/VisarDomi/CleanSlate/tree/testing-event

VisarDomi commented 11 months ago

I'll close this issue for now. If I find some other comparisons that fail, I'll do a pull request again.