• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

LogicSequence

Lightwave Alien
25 Badges
Sep 25, 2006
452
11
  • Stellaris: Humanoids Species Pack
  • Stellaris: Nemesis
  • Stellaris: Necroids
  • Stellaris: Federations
  • Age of Wonders: Planetfall - Revelations
  • Stellaris: Lithoids
  • Age of Wonders: Planetfall
  • Stellaris: Ancient Relics
  • Surviving Mars: First Colony Edition
  • Stellaris: Megacorp
  • Surviving Mars: First Colony Edition
  • Stellaris: Distant Stars
  • Stellaris: Apocalypse
  • Ancient Space
  • Stellaris: Synthetic Dawn
  • Surviving Mars
  • BATTLETECH
  • Stellaris - Path to Destruction bundle
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Stellaris
  • Cities: Skylines - After Dark
  • Cities: Skylines
  • Magicka
  • Crusader Kings II
So i'm trying to restrict an AI country_type from building a custom ship class until 100 years have passed, and then only ever build one at a time. I thought i had the code for that right, but it's not working. Here's what i tried:

Code:
# This is in mod_country_types.txt

ship_data = {
     custom_ship_type = {
        min = 1
        max = 1
        fraction = {
            base = 0
            modifier = {
                factor = 0
                years_passed < 100
            }
            modifier = {
                add = 100
                years_passed > 100
            }
        }
    }
}
 
I presume this is an entirely new country type? Now, I'm not entirely sure about how the system works, but I think one problem is that you're trying to mix both min/max and fractions. Min/Max tells the country to build at least one and maximum one, then the first fraction is completely unnecessary as the ship type starts with 0 factor, which is what you are multiplying by 0. The last fraction tells the AI to assign 100 weight to this ship type when calculating how many ships of each type it should have, which given that the other types would probably tally up to 100 total would mean that it will try to get 50% of its fleet of the given kind. This will also only trigger once, as years_passed does not reset.
 
Try treating the min and max as a fraction.
Code:
min = {
base = 0
modifier = { 
add = 1
years_passed > 100
}
modifier = { 
add = 1
years_passed > 200
}
}

You might be able to do a loop for the modifier, but I don't remember the ins and outs of loops in the system from memory.